Why I got this error? " File "source_file.py", line 3 print(x) ^ IndentationError: expected an indented block " | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why I got this error? " File "source_file.py", line 3 print(x) ^ IndentationError: expected an indented block "

I tried to run this while loop on code play ground, but I got error, can any one tell why? note: I got it from Python lesson! x=0 while x = 20: print(x) x + = 2

6th Oct 2018, 4:42 PM
CodCody
4 Answers
+ 1
which python lesson did you get the code from? after the while statement there should be an indented line, either 2 or 4 spaces usually (should be consistent throughout the file) but the print(x) is not indented (this is what the error message is suggesting). By the look of it the x+=2 should be indented too
6th Oct 2018, 4:55 PM
Dan Walker
Dan Walker - avatar
+ 1
It worked after I fixed line 4 / x+= 2 thnx for the tip :)
7th Oct 2018, 12:35 PM
CodCody
0
I guess I cant post a screenshot! otherwise I could post a screen shot, it's located at infinte while loop, after I finished that lesson I hv got a Q that I filled the blanks to answer, then I copied the code just to test it, it didnt work!
6th Oct 2018, 5:00 PM
CodCody
0
THE TRUMP I tried print(x'\t'), but its the same
7th Oct 2018, 10:32 AM
CodCody