Question:
Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
Program:
1 2 3 |
s = raw_input() words = [word for word in s.split(" ")] print " ".join(sorted(list(set(words)))) |
Explanation:
The string is accepted to s and split to a list using s.split. the list is then sorted and then joined to form the output string
Output:
1 2 |
GLOBALSQL is the best place to learn to code the best GLOBALSQL best code is learn place the to |
Leave a Reply