The initial value is 0, and you should use a temporary variable that adds up every time you receive input."Since ""add in order"", note the ""value added to all the values entered so far"" in the middle."
A specific implementation would be to write a loop that repeats receiving and adding inputs with int(input())
.
While loop is sufficient, request and add a number.Stops the cycle only if the number entered is 0 and you can set another condition.
num=0
while True:
n = int( input("number:")
if n == 0 : break # stop loop
num+=n
print(num)
© 2024 OneMinuteCode. All rights reserved.