How do I fix this “TypeError: 'str' object is not callable” error?

前端 未结 2 1804
野的像风
野的像风 2021-01-02 00:06

I\'m creating a basic program that will use a GUI to get a price of an item, then take 10% off of the price if the initial price is less than 10, or take 20% off of the pric

2条回答
  •  感动是毒
    2021-01-02 00:14

    this part :

    "Your new price is: $"(float(price)

    asks python to call this string:

    "Your new price is: $"

    just like you would a function: function( some_args) which will ALWAYS trigger the error:

    TypeError: 'str' object is not callable

提交回复
热议问题