SumListnums function nums is a list of numbers The function

SumList(nums) function, nums is a list of numbers. The function returns the sum of the numbers in the list You must use an accumulator variable. When correctly implemented, the following test() function will generate 105:

Solution

def sumList(num):
count=0; ## initialising count var to zero
length = len(num)## getting list length
for num in range(length):## adding every number in list to count
count=count+num;## adding
return count## returning count
  
def test():
nums=list(range(15))
print(sumList(nums))
test()

 SumList(nums) function, nums is a list of numbers. The function returns the sum of the numbers in the list You must use an accumulator variable. When correctly

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site