Write a recursive function addElements that returns the sum of the elements in a list. For example, addElements([2,1,3]) gives 6.
def addElements(s):
if s == []:
return 0
else:
s[0] + addElements(s[1:])
return s
Error:
TypeError: unsupported operand type(s) for +: 'int' and 'list'
getting this error, Any help would be good thanks :)
sum(s).