+ 1

IndentationError: expected an indented block

def hello(): ... print("Hi") File "(stdin)", line 2 print("Hi") ^ IndentationError: expected an indented block

14th May 2019, 1:03 PM
Willy dermawan
3 Answers
+ 8
If you're using python in a console/terminal, each new line in a code block begins with '...', but you still need to indent the lines manually. So indent the second line with a tab or a couple of spaces (usually 4). The whole thing should look like this: >>> def f(): ... print('yay') ... >>> f() yay
14th May 2019, 1:21 PM
Anna
Anna - avatar
0
Please link your code
14th May 2019, 1:09 PM
‎ ‏‏‎Anonymous Guy
0
Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include: Forgetting to indent the statements within a compound statement Forgetting to indent the statements of a user-defined function. The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces. The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors . http://net-informations.com/python/err/indentation.htm
2nd Mar 2020, 6:20 AM
rahul kumar
rahul kumar - avatar