Strict Sentence
A sentence is called Strict sentence if it contains all unique words.You can make a sentence strict by removing some words from it such that all remaining words are unique.
You are given a sentence S. You need to write a program to make it strict and print the longest strict sentence possible(Order of words in the given sentence should be preserved).
Note: Words are case-insensitive. For example, Apple, apple, aPPle etc.. are considered the same word.
Input
The first line contains a string S.
Output
The output contains a string which is the longest strict sentence possible.
Explanation
For S = my name is usha my native place is hyderabad.
my and is are not unique words.After removing my and is, the longest possible strict sentence is my name is usha native place hyderabad. So the output should be my name is usha native place hyderabad.
Sample Input1
my name is usha my native place is hyderabad
Sample Output1
my name is usha native place hyderabad
input1 = input('')
l = input1.split()
list1 = []
for i in l:
if (input1.count(i)>=1 and (i not in list1)):
list1.append(i)
print(' '.join(k))
Comments
Leave a comment