Help with max()


#1

Guys, can someone tell me whats going wrong in the below code:

maximum = max(1, 2, 3, 4)

print maximum

This is part of Built-in Function.
It throws below error message:

File "python", line 3, in max
File "python", line 3, in max
File "python", line 3, in max
File "python", line 3, in max
File "python", line 3, in max
RuntimeError: maximum recursion depth exceeded


A good article, definition, or discussion that explains RuntimeError: maximum recursion depth exceeded
#2

Very interesting. It should pass with that code because it is correct. Try copying and pasting mine onto it? Maybe it just needs to be refreshed in the browser or something of that nature. Also, you could try using just three numbers in your mas so have max(1,2,3) or something like that.

maximum = max(1,2,3,4)

print maximum

#3

I tried every possibility... Tried with two numbers, three numbers upto 5 numbers.
Mix of negative integers, floating integers, positive integers.

Are you getting the same error?


#4

Anyone who is getting the output in the max() function..?


#5

Your code is working fine, I don't know why you're having trouble. All that I can recommend is to refresh, change browsers, or even log out and log back in.


#6

Side note:

Isn't this an oxymoron?


#7

Thanks.. :slight_smile:
It worked now after I refreshed the browser and tried.


#8

Awesome, sorry that you had such trouble.


#9

Nope, I passed my lesson with that same set up I gave you just with one less number. I am not sure why it is not passing. But it would seem @kyleaw has helped you enough to pass! :smiley:


#10

Thanks guys!!! :slight_smile:


#11

That, and the fact that you previously got the following error...

RuntimeError: maximum recursion depth exceeded

... suggests that at some time during your editing session, you redefined Codecademy's built in max function in a manner that had the function call itself, which is an example of recursion. Prior to your refreshing the browser, that version of the max function was still in memory, and the following function call set off an infinite recursion that the Python interpreter had to halt ...

maximum = max(1, 2, 3, 4)

#12

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