当前位置 : 主页 > 编程语言 > python >

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

来源:互联网 收集:自由互联 发布时间:2021-08-18
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遍历输出列表中最长的单词

具体代码:

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遍历输出列表中最长的单词的详细内容,更多请关注自由互联其它相关文章!

网友评论