Search code examples
pythonpython-3.xpython-3.7google-api-python-client

ValueError: could not convert string to float: pythonGUI


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: 

Solution

  • 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)