Today we are going to share a Python program to sort words in alphabetic order. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Program to find the factors of a number.
To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # change this value for a different result my_str = "Hello this Is an Example With cased letters" # uncomment 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) |
The sorted words are:
Example
Hello
Is
With
an
cased
letters
this
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.