Posted By

FATAL-1 on 04/02/15


Tagged

loop adding for loops total running


Versions (?)

Running Total


 / Published in: Python
 

Allows a user to input 5 numbers. It then adds them and prints the total.

  1. # Keep a running total
  2.  
  3. total = 0
  4. for i in range(5):
  5. newNumber = int(input("Enter a number: "))
  6. total += newNumber
  7. print("The total is:", total)

Report this snippet  

You need to login to post a comment.