Remove Duplicate words and Sort the string

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:

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:

 

Leave a Reply