diff --git a/Python Program to Sort Words in Alphabetic Order.py b/Python Program to Sort Words in Alphabetic Order.py index f4ebe04a29c..63e0fc36248 100644 --- a/Python Program to Sort Words in Alphabetic Order.py +++ b/Python Program to Sort Words in Alphabetic Order.py @@ -1,18 +1,18 @@ -# Program to sort alphabetically the words form a string provided by the user +# Program to sort words alphabetically and print them out in a list +#declaring variables my_str = "Hello this Is an Example With cased letters" +word_Dict = {} +count = 0 + +#Need to make all words the same case, otherwise, the .sort() function sorts them by ASCII code and they will not appear alphabetically. +my_str = my_str.lower() # 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) +print(words)