Learn

Let’s first quickly review functions in Python.

def bigger(first, second): print max(first, second) return True

In the example above:

  1. We define a function called bigger that has two arguments called first and second.
  2. Then, we print out the larger of the two arguments using the built-in function max.
  3. Finally, the bigger function returns True.

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.
Already have an account?