Ask coding questions

← Back to all posts
Tkinter int() error. pls help!!!!!!
LegendaryWolf (622)

Can you pls tell wut's wrong with my code? Everythings fine but I get an error.

Answered by Coder100 (16825) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (16825)

Basically the error is that c.get() has the value of '' which is not an int.

What you should do instead is to have a try except statement like this:

def convert():
  try:
    result =   int(c.get())  / 5 * 8 + 32 +  " Fahrenheit"
    r['text'] = result
  except:
    r['text'] = 'ERRRORRORORROOROROROROOROR'

that way you can also reliablely and gracefully handle bad input that is not number