I am just learning python and I came across a code for sorting words alphabetically.
My code is:
my_str="Welcome to Python"
words = my_str.split()
words.sort()
print("The sorted words are:")
for word in words:
print(word)
My result comes out as:
The sorted words are:
Python
Welcome
to
I mean it is sorted alphabetically then it should result as
Python
to
Welcome
I am totally confused and unable to proceed forward in learning process, your insights would be so helpful.