write a python program to count the number of unique words in a string of words?
Answers
Answered by
0
Answer:
from collections import Counter
str1 = input("Please enter a sentence: ")
words = str1.split(' ')
c = Counter(words)
unique = [w for w in words if c[w] == 1]
print(f"{len(unique)} unique words.")
Hope this helps - have a great day!
Similar questions
Math,
17 days ago
Math,
17 days ago
Hindi,
1 month ago
Social Sciences,
9 months ago
English,
9 months ago