Q:

python-tkinter error (unsupported operand type(s) for *: 'Entry' and 'float')

from tkinter import*
def final_calculation (event):
    steal = float(amount_steal.get())
    output_steal = (amount_steal * steal_c02 *c02_coal)
    sumEntry.insert(0, sum)

root = Tk()
steal_c02 = float (5.5)
c02_coal = float (0.94)

amount_steal = Entry(root)
amount_steal.pack(side=LEFT)

equalButton = Button(root, text= "=")

equalButton.bind('<Button-1>', final_calculation)
equalButton.pack(side=LEFT)

sumEntry = Entry(root)
sumEntry.pack(side=LEFT)

root.mainloop()

and the error i get is
Exception in Tkinter callback
Traceback (most recent call last):
 File "C:\Users\User\Anaconda3\lib\tkinter\__init__.py", line 1699, in 
__call__
 return self.func(*args)
 File "<ipython-input-32-5bd239601a92>", line 4, in final_calculation
 output_steal =  float(amount_steal * steal_c02 *c02_coal)
*TypeError: unsupported operand type(s) for *: 'Entry' and 'float'

It all works fine until i try to calculate the sum please note im a complete noob when it comes to tkinter any help would be very useful 
kind regards 
49.95

A:

The problem here is that in line 4, instead of using the variable steal (which you have assigned the value in amount_steel), you have used the amount_steel variable, which does not store the value in the textbox, but rather the object representing the textbox.
To fix this, simply change line 4 to:
output_steal = (steal * steal_c02 * c02_coal

However, there is another issue here, which could potentially occur if the user enters a value which isn't convertible to a float: if the user enters a value like "twenty" or "1.1.", then your program will stop. This is fixable by testing to ensure that the entered value is indeed convertible to a float, like so:
def final_calculation(event):
    steal = amount_steal.get()
    try:
      float(steal)
    except ValueError:
      #code to notify user of invalid value
      return #don't return anything to stop the calculation

#rest of code here

