0
Stuck on door the math
Trying to figure out how to loop through user input, add it all up, and then also break when the user says “stop” I tried a single variable and got a type error (which is expected). I tried a second variable and no longer get the error but instead the output doesn’t add up correctly. sum = 0 while True: x = int(input()) y = input() sum += x print(sum) if y == "stop": break Any advice?
5 Respostas
+ 5
This question has been common lately, so please refer to the attached code.
Substitute "stop" for "exit"
https://code.sololearn.com/cBrr1eG5DV2t/?ref=app
+ 1
Ahhh that makes sense. In the challenge they provide the while loop and tell you to drop your code below it. Didnt occur to me to change the loop. Thanks!
+ 1
I haven't seen the challenge.
If it is specific to using break, then I could alter the code to show how to use the break function.
Would you like to try yourself first?
+ 1
Yeah I’ll give it a go.
+ 1
John Corbin
Good choice buddy!
Let us know how you go