Skip to content

Instantly share code, notes, and snippets.

@kryptykphysh
Created September 5, 2013 05:29
Show Gist options
  • Save kryptykphysh/6446380 to your computer and use it in GitHub Desktop.
Save kryptykphysh/6446380 to your computer and use it in GitHub Desktop.
Showing how a Python return value needs to be inside the body of a function.
# Working function
def my_function(parameters):
# Body of the function goes here
return 'stuff returned' # Note, this has to be indented fourspaces to be inside the function.
# This function returns a Syntax Error
def my_function(parameters):
# Body of function
return 'stuff returned' # This returns a Syntax Error as the return statement
# is outside the function definition.
@Murfomurf
Copy link

Thanks for this- the indentation of some commands is a real bugger! I thought this sort of strict formatting went out with cassette tapes! I'll get used to it- just need a little list of rules that makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment