Celsius to Fahrenheit method doesn't work Celsius to Fahrenheit method doesn't work tkinter tkinter

Celsius to Fahrenheit method doesn't work


The type of n is str. This needs to be converted into FLOAT before the calculation.

n = float(celsius_entry.get())


Here is the full code of a working example:

from tkinter import *degree_sign= u'\N{DEGREE SIGN}'window = Tk()window.title( '%cF -> %cC' % (degree_sign,degree_sign) )entry = Entry( window )entry2 = Entry( window )def celsius_to_fahrenheit():    n = float(entry.get())    result = (n * (9/5)) + 32    entry.delete(0, END)    entry2.delete(0, END)    entry2.insert(0, result)def fahrenheit_to_celcius():    n = float(entry2.get())    result = (n -32) / (9/5)    entry2.delete(0, END)    entry.delete(0, END)    entry.insert(0, result)label = Label(window, text = 'Enter Celcius')label.grid( row=1,column=1)entry.grid( row=1,column=2 )btn = Button( window , text = 'Convert to Farenheit' , command=celsius_to_fahrenheit )btn.grid( row=1,column=3 )label2 = Label(window, text = 'Enter Farenheit')label2.grid( row=2,column=1)entry2.grid( row=2,column=2 )btn2 = Button( window , text = 'Convert to Celcius' , command=fahrenheit_to_celcius )btn2.grid( row=2,column=3 )window.mainloop()