Alphabet sorter

sravan953 0 Tallied Votes 158 Views Share

A code snippet which accepts a word or a sentence from a user, and then sorts it, and displays the sorted list.

# An empty list
sorter=[]

# A for loop to add whatever the user enters to the list
for a in (raw_input("Enter some words/letters to sort in alphabetical order: ")):
    sorter.append(a)

print sorted(sorter)