0

24.2 Python Beginner indentation error continue, what should I do?

I get an indentation error for the continue statement. If I put continue in the if statement, it says I should put on the same indentation level as the while loop. If I put continue on the same level as the while loop, I get an error message the indentation level is not correct. What should I do?

2nd Aug 2022, 10:24 AM
Natalie Klein Tijssink
Natalie Klein Tijssink - avatar
6 odpowiedzi
+ 2
Natalie Klein Tijssink Post your code here so we can ser it
2nd Aug 2022, 10:27 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
You indent after the while: and indent further after the if: Essentially every time you have a colon : you will indent the next line(s) that fall in that code block. It doesn't really matter how much you indent but the indenting and unindent matter for the flow. while age >= 3: total += 100 if age < 3: continue
2nd Aug 2022, 1:37 PM
Brandon
Brandon - avatar
+ 2
Natalie Klein Tijssink There are more issues. To get proper help, pls do the following: 1. Edit your question description 2. Add a link to your code in Code Playground 3. Explain what the code should do 4. Tell the error you got That said, the while loop exit condition depends on a variable that doesn't change inside the loop. With the steps I listed above, we will know what to help you on.
4th Aug 2022, 3:10 AM
Emerson Prado
Emerson Prado - avatar
+ 1
total = 0 #your code goes here age = int(input()) while age >= 3: total += 100 if age < 3: continue print(total)
2nd Aug 2022, 11:30 AM
Natalie Klein Tijssink
Natalie Klein Tijssink - avatar
0
While age >= 3: total += 100 If age < 3: continue Your If statement was inside your while bracket. See how i brought it out. That should solve your indentation problem
3rd Aug 2022, 2:50 AM
Precious Okike
0
I have tried both solutions above, but the code is still not running.
3rd Aug 2022, 11:29 AM
Natalie Klein Tijssink
Natalie Klein Tijssink - avatar