Skip to main content

program to sort words in decreasing order of their length and display the words along with their length in python

 my_str = "i am a person who are u"

# breakdown the string into a list of words

words = my_str.split()


words.sort(reverse=True,key=len)

# display the sorted words

for word in words:

print(word,len(word))

Comments

Popular posts from this blog

unix commands