This error occurs because Python expects an indented block of code after defining a function. To fix this error, you need to indent the code inside the function. For example:

def calculate_total():
    total = 2 + 4
    print(total)

calculate_total()

Make sure that the code inside the function is indented with four spaces or a tab.

pythonProject1venvScriptspythonexe EpythonProject1mainpy File EpythonProject1mainpy line 3 total=2+4 ^IndentationError expected an indented block after function definition on line 1进程已结束退出代码为

原文地址: https://www.cveoy.top/t/topic/ioC0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录