Skip to content

Commit 37e3501

Browse files
Merge pull request seeditsolution#343 from Aakashtiwari007/patch-2
SortWordsinAlphabeticOrder
2 parents 4c81300 + 9db4295 commit 37e3501

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Sort Words in Alphabetic Order.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Program to sort alphabetically the words form a string provided by the user
2+
3+
my_str = "Hello this Is an Example With cased letters"
4+
5+
# To take input from the user
6+
#my_str = input("Enter a string: ")
7+
8+
# breakdown the string into a list of words
9+
words = my_str.split()
10+
11+
# sort the list
12+
words.sort()
13+
14+
# display the sorted words
15+
16+
print("The sorted words are:")
17+
for word in words:
18+
print(word)

0 commit comments

Comments
 (0)