L1/10

Reading a Value by Key

A dictionary stores values by key instead of by position.

python
player = {"class": "mage", "level": 5}
print(player["class"])

Here is what the example does:

  • player creates a dictionary and stores it in player.
  • print(player['class']) displays the result of player['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 player to {'name': 'Ayla', 'level': 3}.
  • Print player['name'].

Your finished program should print exactly this output:

text
Ayla

Be very careful with capitalization, spaces, and line breaks. The output must match exactly.