A Python Program to Sort Words in Alphabetical Order
In this post i am describing how to sort words in alphabetical order. The following is a python program to sort words in Alphabetical order.
Output
The sorted words are:
H I J K L N O R U V Z a b c d e f g m p q s t w x y |
Explanation
Firstly I defined a string S. Here S.split ( ) method splits/breakdown the string into a list of words and is stored in a variable ‘words’. To sort those list of words we use sort( ) method. After sorting the list of words we use for loop to print the finally sorted list of words.
We can also print the sorted list of words from a sentence. This is shown in below example.
Output
The sorted words are:
Learn VMS Way a new provides things to |