To solve Python SyntaxError :’return’ outside function error follow below methods.
ERROR LOG
File "value.py", line 4
return False
^
SyntaxError: 'return' outside function
How to solve Python SyntaxError :’return’ outside function ?
When you specify a return statement outside of a function, the “SyntaxError:’return’ outside function” error is raised. To correct this problem, ensure that all of your return statements are properly indented and appear inside a function rather than after it.
The below code raises the following error as their is a indentation error. The return statement should be inside the function not outside.
def prime_num(n):
#code
return True
The correct syntax should be as below:
def prime_num(n):
#code
return True
Hope the above solution works. TypeError: unhashable type: ‘list’
Also read :