Need to restart even after correction in real time

n1=int(input(“Enter number one.\n”))
n2=int(input(“Enter number two.\n”))
l1=
l1m=0
l2m=0
max = max(n1,n2)
print(max)

Explanation: I wrote this program and found that the max should not be name of variable.
But when I did correction in real time it still showed same error. As below. So to solve this error
it is required to restart the session. And is not corrected in real time.


TypeError Traceback (most recent call last)
Cell In[5], line 6
4 l1m=0
5 l2m=0
----> 6 max = max(n1,n2)
7 print(max)
8 # for i in range(2, max):
9 # if (n1%i==0) & (n2%i==0):
10 # l1.append(i)
(…)
13
14 # print(l1m)

TypeError: ‘int’ object is not callable

If you run this in a Python console/ interpreter triggered to open from and in the command line, I suspect you get the same result, and so this post isn’t a Jupyter issue pertinent to this forum. Please always consider that straightforward assessment when deciding where to post seeking help.

That being said quite a few people here do know Python and to help you maybe better ask your question elsewhere if you still need help, let me follow-up with this:
Your post isn’t clarifying what you mean by doing the correction in real time? Or how you did that supposed correction? Or maybe I’m not seeing it because you think you are correcting it but indeed are not. Once you break max in the session by shadowing it, even when in a running Python console, it isn’t going to work until you clear out that process. This is because you will have destroyed max working in that namespace and unless you were super thorough in restoring the internal code that defined max inside Python, it won’t work.

You probably want to review the concept of ‘shadowing’ as it pertains to Python coding if you haven’t come across it before. You may also want to see my note at the bottom of an answer here about naming things being a hard thing that comes up in computer science.

1 Like