Taking a Vacation--Before We Begin


This is the lesson where I am stuck:

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():
    return answer()
    print answer()


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.


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