首页  >  文章  >  后端开发  >  python遍历输出列表中最长的单词

python遍历输出列表中最长的单词

王林
王林原创
2020-05-10 09:35:3610343浏览

python遍历输出列表中最长的单词

python遍历输出列表中最长的单词

具体代码:

word_len_list = [len(word) for word in list]
max_word_len = max(word_len_list)
for word in list:
    if len(word) == max_word_len:
            #print(word)
        list = []

推荐教程:python教程

以上是python遍历输出列表中最长的单词的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn