fork download
  1. #This program calculates the total of the values # in a list
  2.  
  3. def main() :
  4. #Create a list
  5. numbers = [2, 4, 6, 8, 10]
  6. #Create a variable to use as an accumulator
  7. total = 0
  8. #Calculate the total of the list elements
  9. for value in numbers :
  10. total += value
  11. #Display the total of the list elements
  12. print('The total of the elements is', total)
  13. #Call the main functions
  14. main()
Success #stdin #stdout 0.08s 14064KB
stdin
Standard input is empty
stdout
The total of the elements is 30