Use Python:
# Problem Set 03:
- Write a program to input an uncertain string *S* of words and
space/tab
- Remove space/tab in S
- Remove identical words
- Sort all words in the order of a-z
- Print the output strings
- Example:
- Input String: "hello world and practice makes perfect and hello
world again"
- Output String: "again and hello makes perfect practice
world"
- Tips:
- use *set* to remove identical words,
- use *sorted()* to sort words
- use *split()* to remove space
Python code:
#accepting string
string=input()
#printing the string after removing space, identical words and
after sorting them
print(*sorted(set(string.split())))
Screenshot:
Input and Output:
Get Answers For Free
Most questions answered within 1 hours.