Sum Mixed Values

Real data often arrives in a messy mix: some numbers are already integers, while others are stored as strings. Write sum_mix, which takes a list arr, converts every element to an integer, and returns the total sum. The strings inside the list contain only numbers, so they can be converted safely.

Примеры

Ввод
[9, 3, "7", "3"]
Вывод
22
Ввод
["5", "0", 9, 3, 2, 1, "9", 6, 7]
Вывод
42
Ввод
["3", 6, 6, 0, "5", 8, 5, "6", 2, "0"]
Вывод
41

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

def sum_mix(arr: list) -> int:

Теги

arraystringsmath
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
[9,3,"7","3"]
Expected22
2
Input
["5","0",9,3,2,1,"9",6,7]
Expected42
3
Input
["3",6,6,0,"5",8,5,"6",2,"0"]
Expected41
4
Input
["1","5","8",8,9,9,2,"3"]
Expected45
5
Input
[8,0,0,8,5,7,2,3,7,8,6,7,"1"]
Expected62
6
Input
[9]
Expected9
Focus radio
Paused · SomaFM · Fluid