Add Dictionary Values
A dictionary often stores data by category, like expenses by day or player scores. The function sum_dict_values receives a dictionary d and adds together all its numeric values. If the dictionary is empty, the total should be 0.
Примеры
Ввод
{"a": 1, "b": 2, "c": 3}Вывод
6Ввод
{}Вывод
0Ввод
{"x": 10}Вывод
10Нужно реализовать
def sum_dict_values(d: dict) -> int:
Теги
dictmath
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiVisible tests
1
Input
{"a":1,"b":2,"c":3}Expected
62
Input
{}Expected
03
Input
{"x":10}Expected
104
Input
{"a":-1,"b":1}Expected
05
Input
{"p":5,"q":5}Expected
106
Input
{"b":2,"c":3}Expected
5Focus radio
Paused · SomaFM · Fluid