mcq
Suppose we want to remove all duplicate words (words are separated with single whitespace) in a line, which is accepted by the user. The following code is written to do that. Choose the correct observation based on the code.
s = raw_input()
words = [word for word in s.split()]
print ” “.join(set(words))
A
The code works fine.
B
Instead of print ” “.join(set(words)) it should be print ” “.join(list(words)) to make the code work correctly.
C
Instead of words = [word for word in s.split()] it should be
words = s.split() to make the code work correctly.
D
Instead of print ” “.join(set(words)) it should be print ” “.join(dict(words)) to make the code work correctly.
Leave an answer