python return out of function

后端 未结 1 568
野性不改
野性不改 2021-01-27 07:31

I\'m getting a syntax error in Python, the error:

SyntaxError: \'return\' outside function

That seems pretty self-explanatory but as far as

相关标签:
1条回答
  • 2021-01-27 07:46

    I suspect you are mixing tabs and spaces .. your def has 4 spaces preceding it, subsequently you are using multiple tabs for indentation.

    PEP 8 recommends use of (4) spaces over tabs.

    Also note the following from PEP 8:

    Python 3 disallows mixing the use of tabs and spaces for indentation.

    Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively.

    When invoking the Python 2 command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended!

    0 讨论(0)
提交回复
热议问题