Ubuntu – Python error IndentationError: expected an indented block

14.04python-2.7

I started to learn python , but when I try to make an function I get this error

IndentationError: expected an indented block

I use the terminal and write python then start to write the function like that

>>> def mul (x,y) :
... ans=0
  File "<stdin>", line 2
    ans=0
      ^
IndentationError: expected an indented block

so what is the wrong thing i'm doing

Best Answer

Python uses indentation to determine the grouping of statements. You can use one or more spaces or one or more tab, just that within the same statement always use one or the other. Is recommended to use spaces instead of tabs, but is not required. Read here

Try:

>>> def mul (x,y) :
...   ans = 0
...   print ans

with 2 before ans=0.

Read here for complete documentatio of python.