135k views
0 votes
Build dictionary

Create a program to build a dictionary by repeatedly asking the user for a name and a score. Add each to the dictionary with the name as the key and the score as the value. Insure that the value is an integer from 0 to 100. The program should continue to ask for a name and score until the user enters 'end' as the name. At that point, the program should display the dictionary with all the names and scores.

User MagikMaker
by
8.0k points

1 Answer

3 votes

Final answer:

You can build a dictionary by repeatedly asking the user for a name and a score and adding them to the dictionary. The program should validate the score to ensure it is an integer between 0 and 100. Finally, the program should display the dictionary.

Step-by-step explanation:

To build the dictionary, you can use a loop to repeatedly ask the user for a name and a score. Inside the loop, you can add each name and score to the dictionary with the name as the key and the score as the value. Make sure to validate that the score is an integer between 0 and 100. The program should continue asking for input until the user enters 'end' as the name. After that, you can display the dictionary to show all the names and scores.

User Reflective
by
7.7k points