Learn
Let’s first quickly review functions in Python.
def bigger(first, second): print max(first, second) return True
In the example above:
- We define a function called
bigger
that has two arguments calledfirst
andsecond
. - Then, we print out the larger of the two arguments using the built-in function
max
. - Finally, the
bigger
function returnsTrue
.
Now try creating a function yourself!
Instructions
1.
Write a function called answer
that takes no arguments and returns the value 42
.
Even without arguments, you will still need parentheses.Don’t forget the colon at the end of the function definition!
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.