google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Python program to sort alphabetically the words form a string provided by the user

Friday, December 27, 2019

Python program to sort alphabetically the words form a string provided by the user

Python program to sort alphabetically the words form a string provided by the user

Answer:

my_str = input("Enter a string: ")
words = my_str.split()
words.sort()
print("The sorted words are:")
for word in words:
print(word)

Output:
Enter a string: Hello this Is an Example
The sorted words are:
Example
Hello
Is
an
this

No comments:

Post a Comment

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...