# Step 1: Create a list of numbers
numbers = [5, 10, 15, 20, 25]
# Step 2: Initialize a variable to store the sum
total_sum = 0
# Step 3: Use a for loop to iterate through the list
for number in numbers:
    # Step 4: Add the current number to the total_sum
    total_sum += number
# Step 5: Print the result
print("The sum of numbers in the list is:", total_sum)
The sum of numbers in the list is: 75
  1. We start by creating a Python list named numbers that contains a series of integers.
  2. We initialize a variable called total_sum to store the sum of the numbers.This variable is initially set to 0.
  3. We use a for loop to iterate through each element in the numbers list. In each iteration, the current number is assigned to the number variable.
  4. Inside the loop, we add the current number to the total_sum. This is done with the += operator, which is a shorthand way of writing total_sum = total_sum + number. This step accumulates the sum as we iterate through the list.
  5. Finally, outside the loop, we print the result using the print function. The message “The sum of numbers in the list is:” is displayed along with the value of total_sum, which contains the sum of the numbers in the list.


When you run this program, it will calculate the sum of the numbers in the numbers list and print the result. In this example, the sum will be 75 (5 + 10 + 15 + 20 + 25), and that’s what will be displayed by the print statement.