Last answered:

17 Jul 2023

Posted on:

17 Jul 2023

0

Resolved: Max function, error in console

print('Max is', max(data))


However, an error generated says:


TypeError: 'int' object is not callable.


5 answers ( 1 marked as helpful)
Instructor
Posted on:

17 Jul 2023

0

Hey Mohamed,


Thank you for reaching out!


Could you please provide a screenshot of your code?


Kind regads,

365 Hristina

Posted on:

17 Jul 2023

0

Instructor
Posted on:

17 Jul 2023

0

Hey again,


Thank you for the screenshot.


I can't immediately see an issue with the code, it should work without any errors:


Make sure you don't have other uncommented lines except lines 34 and 55. In fact, it would be best if you execute the code in a new file.


Let me know if the issue persists.


Kind regards,

365 Hristina

Posted on:

17 Jul 2023

0

After i checked that i don't have any other uncommented lines, the issue persisted. However, it worked when i taped "remove all variables" button in the variable explorer window, i still don't know what was the problem, but i noticed that there were two variables (max & num) with the same value of 166, might that be the problem ?


Thanks for your help and fast reponse. 

Instructor
Posted on:

17 Jul 2023

0

Thank you for the clarification Mohammed!


Removing the variables has indeed resolved the issue because you've removed a previously declared variable called max (you've given it the same name as the name of the function). Consider the example below:


Using Python keywords as names for variables is a practice you should avoid as it could lead to similar issues.


Kind regards,

365 Hristina :)


Submit an answer