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?
6 Respuestas
+ 2
Natalie Klein Tijssink
Post your code here so we can ser it
+ 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
+ 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.
+ 1
total = 0
#your code goes here
age = int(input())
while age >= 3:
total += 100
if age < 3:
continue
print(total)
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
0
I have tried both solutions above, but the code is still not running.