- 1
How can i adding the user input?
You’re making a calculator that should add multiple numbers taken from input and output the result. The number of inputs is variable and should stop when the user enters "stop". Sample Input 4 32 6 stop Sample Output 42 Use an infinite loop to take user input and break it, if the input equals to "stop".
4 Réponses
+ 2
I did it bro
sum = 0
while True:
x = input()
#your code goes here
if x == 'stop':
break
sum += int(x)
print (sum)
0
can you post your attempt here please?
0
code works perfectly!
input should be as so:
*hit run
1
2
3
4
stop
*hit submit
10 # output
sololearn handles input weird. Each value needs to be placed on a seperate line all at the same time when entering input.
*even if input is needed much later in program it must be included here
0
sum = 0
while True:
x = input()
if x == 'stop':
break
sum += int(x)
print (sum)