Skip to content
Advertisement

tkinter: How to avoid this ValueError: could not convert string to float: ”?

JavaScript

I am trying to make a pound to kilogram converter and basically this gives me the error:

JavaScript

Advertisement

Answer

The function is being called directly when the code is being executed initially, when the entry box is empty, there is nothing inside of it, so you have to remove that and just call the function from the buttons, and also add try and except if you want to prevent entry of anything other than numbers:

JavaScript
Advertisement