different errors, return outside function and others
Terry Reedy
tjreedy at udel.edu
Mon Feb 23 11:51:17 EST 2009
Tony wrote:
> The full error message says "There's an error in your program: ***
> 'return' outside function (final(2).py, line 114)
Ah, you left the quotes off before, and you still omitted the error
class (SyntaxError, see below).
When you are puzzled by an error, try to reduce the executed code to the
MINIMUN needed to get the error. (You can use your editor's block
comment feature -- for IDLE see Format/Comment out [marked] region.)
For your error, the minimum is
>>> return
SyntaxError: 'return' outside function (<pyshell#1>, line 1)
Return statements are only value inside functions and not in module
level code. Perhaps you think you 'return' is in a function but it is
not because it is not indented.
Terry Jan Reedy
More information about the Python-list
mailing list