python错误IndentationError:需要一个缩进块

Fat*_*ind 3 python-2.7 14.04

我开始学习 python ,但是当我尝试创建一个函数时出现此错误

IndentationError:需要一个缩进块

我使用终端并编写python然后开始编写这样的函数

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

所以我做错了什么

gir*_*ngo 5

Python 使用缩进来确定语句的分组。您可以使用一个或多个spaces或一个或多个tab,只是在同一语句中始终使用一个或另一个。建议使用空格而不是制表符,但不是必需的。在这里阅读

尝试:

>>> def mul (x,y) :
...   ans = 0
...   print ans
Run Code Online (Sandbox Code Playgroud)

与 2 之前ans=0

阅读此处以获取 Python 的完整文档。