TypeError: ‘float’ object is not callable when using a while loop to make it end with a trigger

  generics, python, python-3.x

Hi, I’m kinda new to programming and I’m doing a budget thing just to practice. I’m using a while loop to add the money used by the person. Here’s my code so that you understand.

def moneyused():
moneyused = []
while True:
    used=float(input("Type the money you've used, if done, type '0':"))
    if used()==0:
        break
    else: moneyused.append(used)
totalused = sum(moneyused)
print ("You've used $",totalused,"in total.")

I’m trying to make it so that with a trigger word the loop stops, but I can’t use a word since I’m using floats in the input. So I try using a number but every time I type anything I get this error:

Traceback (most recent call last):

  File "<ipython-input-34-b805c6c03014>", line 1, in <module>
    moneyused()

  File "C:UsersjonerDesktopPythonInvento.py", line 42, in moneyused

TypeError: 'int' object is not callable

How can I get around is?

Source: Python Questions

LEAVE A COMMENT