Add the Numbers
Adding a list is a basic operation for receipts, scores, ratings, and many kinds of numeric data. The function sum_list receives a list of numbers nums and returns the total of all its elements. If the list is empty, there is nothing to add, so the result should be 0.
Примеры
Ввод
[1, 2, 3]Вывод
6Ввод
[]Вывод
0Ввод
[10, -10]Вывод
0Нужно реализовать
def sum_list(nums: list[int]) -> int:
Теги
arraylistsmath
Logga in för att se historik över inskick
Logga inLogga in för att använda AI-mentorn
Logga inVisible tests
1
Input
[1,2,3]Expected
62
Input
[]Expected
03
Input
[10,-10]Expected
04
Input
[5]Expected
55
Input
[1,1,1,1,1]Expected
56
Input
[100,200,300]Expected
600Focus radio
Paused · SomaFM · Fluid