>>> def f(x):
... return x**2
File "<stdin>", line 2
return x**2
^
IndentationError: expected an indented block
Asked
Active
Viewed 39 times
-3

Sayse
- 42,633
- 14
- 77
- 146

Vamsi Poduri
- 1
- 1
-
2you need to indent the return statement (add 4 spaces) – Sayse Mar 31 '21 at 10:38
1 Answers
0
Here you are:
>>> def f(x):
... return x**2
...
>>> f(2)
4
Python Indentation
Indentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.
For more information regarding indentation please check this tutorial.

funk
- 2,221
- 1
- 24
- 23