my_str = "you can just put in word in one sentence like this" my_str = input("Enter a string: ") words = [word.lower() for word in my_str.split()] words.sort() print("The sorted words are:") for word in words: print(word)
Here is what the above code is Doing:
1. It’s asking the user to input a string.
2. It’s creating a list of words from the string.
3. It’s sorting the list of words.
4. It’s printing the sorted list of words.