Sort Words in Alphabetic Order Python

PROGRAM TO SORT WORDS IN ALPHABETIC ORDER


my_str = "Hello this Is an Example With cased letters"

# To take input from the user
#my_str = input("Enter a string: ")

# breakdown the string into a list of words
words = my_str.split()

# sort the list
words.sort()

# display the sorted words

print("The sorted words are:")
for word in words:
   print(word)

OUTPUT
The sorted words are:
Example
Hello
Is
With
an
cased
letters
this
CREDITS: https://www.programiz.com/python-programming/examples/alphabetical-order

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java