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
2 Answers
+ 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)
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.