Python - printing multiple shortest and longest words from a list

后端 未结 6 1375
旧时难觅i
旧时难觅i 2021-01-14 05:25


I need to go through a list and print the longest words in it. I can do this for just one word, but can\'t figure out how to print more than one, if there are two words

6条回答
  •  情话喂你
    2021-01-14 05:47

    list.sort (key=len, reverse =True)
    print ("The longest 3 words in the list are: " , list[:3])
    

提交回复
热议问题