Write a program that takes a list of integers as a parameter and returns the sum of the list without using the built-in ‘sum()’ function.
def mysum(L):
s = 0
for x in L:
s += x
return s
L = [1, 2, 3, 4, 5]
print(f'The sum of the list {L} is {mysum(L)}')
Comments
Leave a comment