Indentation error: expected an indented block | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Indentation error: expected an indented block

7th Jun 2017, 6:41 AM
Gokul
Gokul - avatar
3 Answers
+ 5
hi, In python u must follow indentation while writing code but in other lang like java uses curly braces. please use IDLE Python for avoiding such error.
7th Jun 2017, 6:47 AM
Nanda Balakrishnan
+ 3
use an appropriate editor or IDE can you please post the exact code?
7th Jun 2017, 6:58 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
0
There is one extremely common case in which you will encounter that error - when you are trying to create an empty code block, to be filled in later. For example when you are trying to create an empty function: def function_i_need_but_will_actually_write_later(): def another_function(): print ("This one actually has content") The problem is that python requires any code block to have at least one line inside it. So for this exact reason, you have the "pass" keyword - it doesn't do anything, but it allows you to have that required line: def function_i_need_but_will_actually_write_later(): pass def another_function(): print ("This one actually has content")
9th Jun 2017, 8:11 AM
Bogdan Sass
Bogdan Sass - avatar