Home > Back-end >  Getting Error while using min() funtion in jupyter notebook
Getting Error while using min() funtion in jupyter notebook

Time:10-15

I am running same code in pycharm and jupyter notebook ,it works in Pycharm but causing "TypeError: 'float' object is not callable" error while running in notebook

    lst = [-0.8952728022981113, -0.8256266449547354,
       -0.18551647265920335, -0.7845995301231219,
       0.8023977559033892, -0.9236926677953552,
       0.07240408006785382, -0.3356046029806403,
       0.7041732378587373, -0.6806752065560602,
        -0.325566685781449, -0.33240721074208945]

MINIMUM_OF_SUBLIST = round(min(lst),3)
MAXIMUM_OF_SUBLIST = round(max(lst),3)
AVERAGE_OF_SUBLIST = round(sum(lst) / len(lst),3)
print(f"Minimum: {MINIMUM_OF_SUBLIST} / Maximum: {MAXIMUM_OF_SUBLIST} / Average: {AVERAGE_OF_SUBLIST}")

When i run in pycharm it output as Minimum: -0.924 / Maximum: 0.802 / Average: -0.309

but while running in notebook i got error :-

    TypeError                                 Traceback (most recent call last)
<ipython-input-5-638bf02333bb> in <module>
      6         -0.325566685781449, -0.33240721074208945]
      7 
----> 8 MINIMUM_OF_SUBLIST = round(min(lst),3)
      9 MAXIMUM_OF_SUBLIST = round(max(lst),3)
     10 AVERAGE_OF_SUBLIST = round(sum(lst) / len(lst),3)

TypeError: 'float' object is not callable

I don't know whats the issue(:

CodePudding user response:

It seems like you have assigned a value to min earlier in your notebook, as it is now a float when you try to call it.

min is a reserved keyword in Python, so you should rather use something like min_ or min_val.

  • Related