python for loop

Posted by w3diy - 1 year ago

Example: Python for Loop

# Program to find the sum of all numbers stored in a list

# List of numbers
numbers = [11,22,5,6,5,48,4,5,87,74]

# variable to store the sum
sum = 0

# iterate over the list
for val in numbers:
    sum = sum+val

print("The sum is", sum)