Skip to content

Instantly share code, notes, and snippets.

@amackera
Created July 14, 2015 20:26
Show Gist options
  • Save amackera/80704175fb51cee9be62 to your computer and use it in GitHub Desktop.
Save amackera/80704175fb51cee9be62 to your computer and use it in GitHub Desktop.
Examples of return
def addNumbers(x, y):
# Returning a value
return x + y
def printString(string):
# Not returning anything, but just printing to console
print string
def returningEarly(myList):
# This function only operates on lists longer than 2 elements
if len(myList) <= 2:
return
else:
# other stuff would happen here, too lazy
...
# I want to add some numbers
sum = addNumbers(1, 2)
# sum is now 3
# I want to print something
printString('Hello Alex!')
# prints 'Hello Alex!' to console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment