나는 이렇게 학습한다/Algorithm & SQL
1106. Grasshopper - Messi Goals
daco2020
2022. 11. 7. 00:58
Messi's Goal Total
Use variables to find the sum of the goals Messi scored in 3 competitions
Information
Messi goal scoring statistics:
Competition Goals
La Liga 43
Champions League 10
Copa del Rey 5
Task
-
Create these three variables and store the appropriate values using the table above:
-
la_liga_goals
champions_league_goals
-
copa_del_rey_goals
-
Create a fourth variable named total_goals that stores the sum of all of Messi's goals for this year.
Solution:
la_liga_goals = 43
champions_league_goals = 10
copa_del_rey_goals = 5
goals = {
"la_liga_goals": la_liga_goals,
"champions_league_goals": champions_league_goals,
"copa_del_rey_goals": copa_del_rey_goals
}
func = lambda x: sum(x.values())
total_goals = func(goals)