+ 1

# Do the math Practice

sum = 0 while True: x = input() #your code goes here if input == "stop": print ("stop") else: sum += int(input()) print (sum) break I think I missed the mark? Anyway we are required to calculate the sum of user input and break it, if the user inputs (“stop”). Will keep practicing, as before I was just getting Errors, then I managed to get it to just output “stop”. Now I managed to output “2” so I think I should hopefully manage. However just in case I’m not on the right track.

21st Feb 2021, 2:34 PM
Benjamin Ian Awumsuri Benjamin Moshi
+ 3
Oh, yes, you are right. My bad. Anyway, I get error sometimes, because I have indented block message. So the code is good, but place of a code in a line is wrong. But this code should work just fine: sum = 0 while True: x = input() if x == 'stop': break sum += int(x) print(sum)
17th Mar 2021, 3:39 PM
Luiza
+ 2
@Luiza Haas, your code works good on 'Code PlayGround'. It works the same as 'else:' between break and sum += int(x). The problem is that it doesn't work on the problem "shell". Got this error: Traceback (most recent call last): File "/usercode/file0.py", line 7, in <module> sum += int(x) TypeError: unsupported operand type(s) for +=: 'builtin_function_or_method' and 'int' It's kinda crazy o_o PS: Your code did work! The error above was a tiny mistake on my behalf! Thanks alot!!! PSS:Oh and don't writte x == 'Stop' but 'stop'
17th Mar 2021, 3:47 PM
Da Silva Miguel
+ 1
So you're supposed to accept values and add them up until the user enters 'stop', right? If so, then you must break the loop when the user enters 'stop'. So I think the break should be in the if clause and not in the else clause. Correct me if I'm wrong
21st Feb 2021, 2:40 PM
Soumik
+ 1
ANSWER SPOILER: You are so close. Put a break after print(“stop”). You don’t need the break at the end of the code. Then remove indents from your final print. Otherwise, you’ll get a list. sum = 0 while True: x = input() #your code goes here if x == "stop": break sum +=int(x) print(sum)
22nd Feb 2021, 9:21 PM
Ry Guy
+ 1
I have the same problem... If I do the code un 'code playground' eveything works fine but when I do the same code on the problem panel, I get that message. It's a little frustating :/
16th Mar 2021, 9:49 PM
Da Silva Miguel
+ 1
For anyone looking, this worked for me. moving the print sum into the loop was what did it. sum = 0 while True: x = input() if x == ("stop"): print (sum) break else: sum += int(x)
24th Mar 2021, 2:50 AM
Geoff Ross
+ 1
the correct code is the following: sum = 0 while True: x =input() if x == "stop": break else: sum += int(x) print(sum)
23rd Apr 2021, 3:43 PM
Anne Jungers
0
Trace back (most recent call last): File “/ usercode/ file0.py”, line 7 in <module> sum += int(x) ValueError: invalid literal for int() with base 10: ‘stop’ thanks for the assist though,... ill keep working on it
22nd Feb 2021, 10:00 PM
Benjamin Ian Awumsuri Benjamin Moshi
0
Arthur, shouldn't you just use "stop" instead 'stop' ?
16th Mar 2021, 11:28 PM
Luiza
0
It does the same work if it's quote or double-quote.
17th Mar 2021, 3:24 PM
Da Silva Miguel
0
Uff great :):)
17th Mar 2021, 5:18 PM
Luiza
0
İ did finally :) sum = 0 while 1==1: x=input() if x=="stop": break else: sum+=int(x) print(sum)
30th Sep 2021, 5:22 PM
Ünal Tuğrul BULUT
0
As second graders, math can seem overwhelming. The use of worksheets in this grade can help you pinpoint areas of weakness and reinforce previous learning. These worksheets can also help you identify students who thrive in math and those who are struggling. By using these worksheets, you can plan future math lessons to address the weaknesses and strengths of individual students. This way, gifted students will remain motivated and engaged. Listed below are several examples of [https://brighterly.com/worksheets/2nd-grade-math-worksheets/](2nd grade math worksheets). .
23rd Jun 2022, 12:46 AM
Andrew Jackson