Python Program to Sort Words in Alphabetic Order

Created with Sketch.

Python Program to Sort Words in Alphabetic Order

Sorting:

Sorting is a process of arrangement. It arranges data systematically in a particular format. It follows some algorithm to sort data.

See this example:

  1. my_str = input(“Enter a string: “)
  2. # breakdown the string into a list of words
  3. words = my_str.split()
  4. # sort the list
  5. words.sort()
  6. # display the sorted words
  7. for word in words:
  8.    print(word)

Output:

Python Nativ Data Programs5

 

Leave a Reply

Your email address will not be published. Required fields are marked *