114. Python Program to Add or Update a Mark in a Dictionary
EasyChange items
Overview
One line both adds and changes: marks[name] = mark. Your program also tells which one happened.
Problem Statement
The marks are already in the starter code:
marks = {"Sunny": 82, "Rocky": 67}
Read a name, then a mark (a whole number). If the name is already in marks, print Updated and the name; otherwise print Added and the name. Then store the mark under the name and print the dictionary. For example, for Lucky and 91:
Added Lucky
{'Sunny': 82, 'Rocky': 67, 'Lucky': 91}
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value per line, in this order. Example:
Lucky
91
Output
The output for that example:
Added Lucky
{'Sunny': 82, 'Rocky': 67, 'Lucky': 91}
The tests try 3 different inputs.