This is the first message I've ever posted here. I'm new to Python.
I was stuck at the "Iterating over a list in a function" exercise, and after a long while trying to solve it, I finally got the right answerr. The thing is I got two different results, as you can see below. why is it that I kept getting two different results?
What seems to make the difference is the fact that the variable total be after or before the for loop.
Thank you very much, I'm sorry if it's not the right place to post it.
def papa(a): total = 0 for i in range(len(a)): total = total + a[i] return total n = [0,3,6] papa(n) 6 def papa(a): for i in range(len(a)): total = 0 total = total + a[i] return total n = [0,3,6] papa(n) 9