There are numbers to enter, they can be from 1 to 10, it is necessary to calculate the sum of the entered data until a certain condition - when the number "0" is entered. I understand that everything is done using the While loop, but stuck with int (input ()), t .to. the number of numbers that will be entered into the console is not clear

Closed due to the fact that the essence of the question is not clear to the participants 0xdb , Kromster , Jarvis_J , Kosta B. , Viktor Tomilov Jul 13 '18 at 8:50 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What exactly is not clear? There are no psychics, show the code. - Enikeyschik

1 answer 1

If after each entered number press Enter, then:

el_sum = 0 a = int(input()) while a != 0: el_sum += a a = int(input()) print(el_sum) 
  • I forgot that int (input ()) can be inserted into the iteration. Only I used the code without the sum function: a = 0 b = int (input ()) while b! = 0: a + = bb = int (input ()) print (a) - eod
  • @eod sum is a common variable in this case, and the function :) is RiotBr3aker
  • one
    sum is a standard function in python, it’s not worth overriding it - slippyk
  • @Vlasivirin correct, please, the name of the variable sum, since it really confuses, and in addition, it will cause an error when trying to use the standard function sum (...). Redefinition - Bad - RiotBr3aker