Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 276 Bytes

For loop in python.md

File metadata and controls

15 lines (11 loc) · 276 Bytes

example 1

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

  • List of numbers numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]

  • variable to store the sum sum = 0

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

  • Output: The sum is 48 print("The sum is", sum)