Reading a Value by Key
A dictionary stores values by key instead of by position.
player = {"class": "mage", "level": 5}
print(player["class"])Here is what the example does:
playercreates a dictionary and stores it inplayer.print(player['class'])displays the result ofplayer['class'].
The assignment changes the specific values, but the basic pattern is the same.
Assignment
Complete the starter code so the program does the following:
- Set
playerto{'name': 'Ayla', 'level': 3}. - Print
player['name'].
Your finished program should print exactly this output:
AylaBe very careful with capitalization, spaces, and line breaks. The output must match exactly.