Jun-16-2018, 12:25 AM
Given an array of ints (as a list), print the sum of all the elements.
My code:
My code:
L=[1, 1, 1, 2] x=0 def sum3(nums): for i in nums: x+=i print(sum3(L))How is x a local variable if I define it outside of the loop?