I think there's a bug for Beginner Python Practice 24.2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

I think there's a bug for Beginner Python Practice 24.2

My code looks like this: total = 0 x=0 while x<5: age = int(input()) if age>3: total+=100 if age<=3: break print(total) x+=1 If age is more than 3, the results say it only wants me to show the sum and not any of the work. But I haven't been taught to skip showing numbers besides using "break". Also the second input/trial in which the input numbers were 1,2,1, is also weird because the result they wanted was 100 but they clearly told me to add 100 only for when age>3.

26th Sep 2022, 3:47 AM
Qing Wu
Qing Wu - avatar
5 Answers
+ 2
Well, firstly, the task is not 24.2, but 26.2. Secondly, the fact that you did not begin to learn a lesson about "continue" does not mean that it was not provided to you. And thirdly, in the second test, the input numbers were 1,2,1,2,5, you just had to scroll down. 😉 P. S: By the way, this task can be solved without "continue".
26th Sep 2022, 5:23 AM
Solo
Solo - avatar
+ 2
Qing Wu , there are some issues to fix: (1) by using `break` the while loop will be exited, so it is not guaranteed that all 5 required inputs are given. you can use `break` instead. (2) increment of the input counter is not at the correct place. it should be in the line after input() (3) the output with `print(total)` is currently inside the loop, which is not correct in terms of indentation. move it to the most left position
26th Sep 2022, 9:45 AM
Lothar
Lothar - avatar
+ 1
Solo , thank you for your insight but i'm certain it is 24.2, as it is about ticket prices. I'm unable to even go to lesson 25 without passing the practice. I did learn about "continue" in the same lesson, however I'm confused as to where to put it because when the code doesn't work or doesn't do anything when I put "continue" after either the first if or the second if statement. I'm sure this task can be solved without "continue", I'm just trying to practice "break" and "continue" to see how it works. Maybe it's a problem on my side but I appreciate you taking the time to advise me.
27th Sep 2022, 4:39 AM
Qing Wu
Qing Wu - avatar
+ 1
Lothar , Thank you for your advice! I did not notice that the output being out of place was a part of the issue. Fixing it helped my code to just show the sum! Thank you so much!
27th Sep 2022, 4:49 AM
Qing Wu
Qing Wu - avatar
+ 1
Qing Wu , we have different SoloLearn apps 😅 And yes, I can see that you are not learning Python at all on SoloLearn. 🤔 Once again, carefully read the lessons for this task It's very simple. "break" - stops the cycle; "continue" - simply skips (ignores) all commands written after it in the loop.
27th Sep 2022, 10:16 AM
Solo
Solo - avatar