In Python, I want to convert all strings in the list to integers.
My task: I have to simply sum some integers. However, I cannot use in code the following: for,while,sum,map,reduce,filter,import,eval,exec,compile,single.
Sample Input 0:
1 2 3 4
Sample Output 0:
10
So if I have:
ls = ['1', '2', '3']
How do I make it:
ls = [1, 2, 3]
def listSum(ls):
def recursion(index, result):
if index == len(ls):
return result
return recursion(index + 1, result + ls[index])
return recursion(0, 0)
ls = (input()).split()
ls = list(map(int, ls))
# print((ls))
print(listSum(ls))