0
costOfItem = (Item1 * 10) + (Item2 * 20)\
                              + (Item3 * 30) + (Item4 * 40) + (Item5 * 50) + (Item6 * 60) + (Item7* 70) + (Item8* 80)
                 SubTotalofITEMS = "Rs.", str('%.2f'% costOfItem)

                 SubTotal.set(SubTotalofITEMS)
                 Tax="Rs.", str('%.2f'% ((costOfItem) * 0.08))
                 GSTTax.set(Tax)
                 TTax = ((costOfItem) * 0.08)

                 TCost = "Rs.", ('%.2f'% (costOfItem + TTax))
                 TotalCost.set(TCost)

I'll Makaing Python GUI Restront billing management system.But I'M facing problem to costofItem in calculation.....

 **strong text**
   Error showing 
    t__.py", line 1705, in __call__
        return self.func(*args)
      File "C:\Users\Lenovo\Desktop\Py.Billing system - Copy.py", line 252, in costOfItem
        Item1=float(Tea.get())
    ValueError: could not convert string to float: 

2 Answers 2

1

The value that you are trying to convert to a float from a string is likely not a number, you can check for this by using the built-in method isnumeric

As for what the value currently contains I wouldn't know but I would suggest printing the value before it fails to see if it is a value you are not expecting.

x = Tea.get()
if x.isnumeric():
    float(x)
else:
    print(f"x is not a float is is: {x}")
Sign up to request clarification or add additional context in comments.

1 Comment

I am not telling you that is the answer I'm telling you that whatever you are trying to convert is not a number.
0
costOfItem = (Item1 * 10) + (Item2 * 20)\
                              + (Item3 * 30) + (Item4 * 40) + (Item5 * 50) + (Item6 * 60) + (Item7* 70) + (Item8* 80)
                 SubTotalofITEMS = "Rs.", str('%.2f'% costOfItem)

                 SubTotal.set(SubTotalofITEMS)
                 Tax="Rs.", str('%.2f'% ((costOfItem) * 0.08))
                 GSTTax.set(Tax)
                 TTax = ((costOfItem) * 0.08)

                 TCost = "Rs.", str('%.2f'% (costOfItem + TTax))
                 TotalCost.set(TCost)

1 Comment

Now, I Find the Error, It's work properly... TCost = "Rs.", str('%.2f'% (costOfItem + TTax))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.