Exercise 9 · Chapter: DictionariesOptional+50 XP
Fix the Loop
This program loops over a dictionary of ages but prints the wrong values. Fix it so it prints each person's actual age!
Expected output:
Alice is 10 years old Bob is 12 years old Charlie is 11 years old
Need a hint?
3 available · costs 5 XP each
python
ages = {"Alice": 10, "Bob": 12, "Charlie": 11}
for name in ages.keys():
print(name, "is", name, "years old")
Output
Run your code to see the output here.