I would be very grateful if someone could take the time to explain exactly whats happening in the below code. I have it working, no problem, but I don't want to move on until I really grasp whats happening. The part that has me confused is the range. The list 'n' isn't really a list? its a range? and therefore, all that this code is doing is adding up the total (3+5+7 = 15) and adding a 1 to variable 'result' for the total length of the range 'n' (15)?
Am I correct in this? or am I missing something..
n = [3, 5, 7] def total(numbers): result = 0 for i in range(len(numbers)): result = result + numbers[i] return result print total(n)
thanks for any input!