def functionCreator(txt):
def createdFunction(newTxt):
return txt + " " + newTxt
return createdFunction
print(functionCreator("hello")("world"))
def example_function(input):
output = input + 1
return output
def example_function():
return "Example"
def function():
x = "random"
print("random")
return x
a = function() #Runs line 3, makes a the return value ("random")
# Here we define the function with a parameter
# At the return statement, function ends execution
# And return the value or result of the code block
def greet(lang):
if lang == 'spanish':
return('Hola!')
elif lang == 'french':
return('Bonjour!')
else:
return('Hello!')
# Now we can call the function and print the returning value
print(greet('spanish'), 'Lucia.') # Output - Hola! Lucia.
print(greet('french'), 'Emma.') # Output - Bonjour! Emma.
print(greet('english'), 'James.')# Output - Hello! James.
return [expression_list]
def a():
def b():
return "xxxxxxxxx"
return b
print(a()())