Beginner question, I have to create a program that asks user to input numbers (input 0 to break), then calculates the amount of numbers in total and then the sum of the input numbers.
How do i print the sum of user-input numbers using while loop? This is what I got so far
amount = 0
while True:
amount += 1
number = int(input("Number: "))
if number == 0:
break
print(f"Numbers in total: {amount-1}")
>Solution :
You are close. Same as you have amount = 0, create a variable total = 0. And, inside the loop, add total += number, after the line where you are reading it.