0

24.3 python please correct my code from Break

sum=0 X=int(input()) While x!=“stop” sum+=x print(sum) if x==“stop” break print(sum) The problem requires me to spend more than 2 weeks till now. It keeps telling me that the break is not in the loop or the file is too long. Please help me how I can pass this stage, without it I can’t move on to the next. I’ve subscribed this app for a year already, and feeling miserable. #python #24.3 #let’s count #break #practice

13th Nov 2021, 4:57 AM
t029박현민
t029박현민 - avatar
2 ответов
+ 3
#do it like this sum = 0 while True: x = input() if x != "stop": sum += int(x) else: break print(sum) #if you're familiar with walrus operator (:=) sum = 0 while (x := input()) != "stop": sum += int(x) print(sum)
13th Nov 2021, 7:28 AM
Simba
Simba - avatar
0
sum = 0 x=int(input()) while x!="stop": sum+=x if x=="stop": break print(sum) This is the part I originally typed. The one I presented above was automatically changed into capital since I typed through ipad. Still I’m using it but much more with care. You’re not giving me any concrete help. I need solution. If you don’t bother, I would like you to concentrate to the questions I suggested at the bottom how I make Break in the loop. I’m still learning it.
13th Nov 2021, 6:51 AM
t029박현민
t029박현민 - avatar