Football Team Records
Python
25 pts
Football Team Records
A school football team is stored as a nested dictionary:
team = {
"Selam": {"city": "Asmara", "goals": 4},
"Abel": {"city": "Keren", "goals": 7},
"Merhawi": {"city": "Massawa", "goals": 2}
}
- Print Abel’s city.
- Merhawi scored one more goal: add 1 to his
"goals". - Print
Merhawi goals:followed by his new number of goals. - Loop through the team and add up all the goals in a variable called
total_goals. - Print
Total goals:followed by the total.
Expected output:
Keren Merhawi goals: 3 Total goals: 14
Checklist
- Add one goal to Merhawi without changing the other players.
- Add up the goals of the whole team in
total_goals. - Print Abel's city, Merhawi's new goals and the total, as shown.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
