Question

You are learning a new language, and are having a competition to see how many unique...

You are learning a new language, and are having a competition to see how many unique words you know in it to test your vocabulary learning.

Write a program where you can enter one word at a time, and be told how many unique words you have entered. You should not count duplicates. The program should stop asking for more words when you enter a blank line.

For example:

 
Word: Chat
Word: Chien
Word: Chat
Word: Escargot
Word: 
You know 3 unique word(s)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

# using set() to avoid duplication

words=set()
  
while(True):
   word=input("Word: ")
   if(word==""):
       break;
   words.add(word)

uniqueWords=str(len(words))

print("You know", uniqueWords,"unique word(s)")

Program Screenshot:

CountUnique Words - Notepad File Edit Format View Help #using set() to avoid duplication words=set() while(True): word=input(

Output:

Windows PowerShell - OX PS C:\Users\user\Desktop> py CountUniquewords.py Word: Chat Word: Chien Word: Chat Word: Excargot Wor

Add a comment
Know the answer?
Add Answer to:
You are learning a new language, and are having a competition to see how many unique...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT