[SOLVED] How to jump to the next line when defining a function in Python?


I am using a Mac terminal to learn Python basics at the moment and I can’t figure out how to write a new line when defining a function, because whenever I hit "Enter", it just throws an error.

        >>> def f():
        ... a = 10
          File "<stdin>", line 2
            a = 10
        IndentationError: expected an indented block after function definition on line 1


Indentation indicates where blocks begin and end. Everything inside a function definition is indented:

>>> def f():
...     a = 10
...     print(a)
>>> f()

The first line that is not indented indicates the function is over.

Answered By – Samwise

Answer Checked By – Gilberto Lyons (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *