Write a Python function to sum all the numbers in a list



   code:-
def sum(numbers):
    total = 0
    for n in numbers:
        total += n
    return total
print("Sum of numbers:")
print(sum((10, 20, 30, 60, 70)))
output:-
Sum of numbers:
190
>>> 

exmple 2:-

def sum(numbers):
    total = 0
    for x in numbers:
        total += x
    return total
print(sum((8, 2, 3, 0, 7)))

output:-
20
>>> 

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post