Add Array Values

Programs often need to quickly calculate a total, such as a sum of purchases, points, or views. The function simple_array_sum receives a list of integers ar. Return the sum of all elements in the list; if the list is empty, the sum is 0.

Примеры

Ввод
[1, 2, 3, 4, 10, 11]
Вывод
31
Ввод
[]
Вывод
0
Ввод
[5]
Вывод
5

Нужно реализовать

def simple_array_sum(ar: list[int]) -> int:

Теги

arraymath
PostgreSQLv16

Itt jelenik meg a kód futtatásának eredménye

Visible tests
1
Input
[1,2,3,4,10,11]
Expected31
2
Input
[]
Expected0
3
Input
[5]
Expected5
4
Input
[-1,-2,-3]
Expected-6
5
Input
[0,0,0,0]
Expected0
6
Input
[5,5]
Expected10
Focus radio
Paused · SomaFM · Fluid