Computer Science, asked by jotirmoymld101p2t591, 1 month ago

write a python program to count the number of unique words in a string of words?​

Answers

Answered by TheArkhamKnight
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