0

Can someone help? I've been stuck on this problem for a few days now.

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 "stop". https://code.sololearn.com/cc4W85i4NoGY/?ref=app

23rd Sep 2021, 7:21 AM
Crispy
4 Réponses
+ 4
You print the result in every iteration of the loop. You should only print the final result. Just unindet your print statement.
23rd Sep 2021, 7:27 AM
Simon Sauter
Simon Sauter - avatar
+ 3
use this: x =input() c=0 while x!='stop': x=int(x) c+=x x=input() print(c)
23rd Sep 2021, 8:16 AM
Amirreza
Amirreza - avatar
0
Move print(sum) into tje if statement when x=="stop" before break.
23rd Sep 2021, 7:27 AM
Magne
Magne - avatar
0
Thank you, I can't believe thats all it was.
23rd Sep 2021, 7:31 AM
Crispy