Question #3241

Write a program that repeatedly asks a user to enter a number. The program will sum up all the number that the user keyed in. Terminate the program when the user enters -9, and display the sum of all the numbers entered by the user (exclude -9).

Expert's answer

sum = 0

while True:

number = float(input ("Enter a number: "))

if number == -9: break

sum += number

print ("The sum is", sum)
LATEST TUTORIALS
APPROVED BY CLIENTS