Taking a Vacation--Before We Begin


#1



This is the lesson where I am stuck:
https://www.codecademy.com/en/courses/python-beginner-P5YtY/0/1?curriculum_id=4f89dab3d788890003000096


The error I get is:
"Maximum recursion deplth exceeded."


I need to print 42.

Below is the code I used. I know the correct code is to just return 42 and then print it, but why don't we define answer() as 42? Otherwise there is no connection between the def line and the return line. Help please.

def answer():
    answer()==42
    return answer()
    print answer()


#2

For one, you can't set a function equal to a value. That makes no sense. For two if you return the function when you run the function, it just keeps going down and running the function over and returning the function over and over. Answer is a function. When you def a function, the return is the end of the function and what it gives you back. So if you return 42 from the answer() function, that is the connection.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.