This function works only when I call with:
def prodo(L):
sum = 1
for i in range(0, len(L)):
sum = L[i] * sum
return sum
these lines:
d = prodo([3, -1, 4, -1, -5])
print(d)
But the following function using L
returns 375 and not -60
def prod(L):
sum = 1
for i in L:
if i>=len(L):
break
sum = L[i] * sum
return sum
Question: What am I doing wrong and why?