Dec-03-2022, 03:59 AM
This cannot be:
This is a simpler example.
To fix the problem you need to rename the function or the variable used to hold the float value.
def average(message): global averageWhen your python compiles your program it creates a variable named "average" that references a function. Later in the program you reassign that variable to be something else. Now "average" no longer references the function and you cannot call average(arguments).
This is a simpler example.
def average(*args): global average average = sum(args) / len(args) print(average) average(1, 2, 3, 4) print(average) average(1, 2, 3, 4)
Error:<function average at 0x000001DD4E586160>
2.5
Traceback (most recent call last):
File "c...", line 8, in <module>
average(1, 2, 3, 4)
TypeError: 'float' object is not callable
You can see in the output that "average" starts out referencing a function. The function is called and it reassigns average to be the average of 1, 2, 3, 4. Now there is no way to call the average function. The name (essentially what variables are in python) us being used to reference a float number, not a function.To fix the problem you need to rename the function or the variable used to hold the float value.