Explanation
Lines 32-35 were
feet = float(values["feet"])
inches = float(values["inches"])
result = convert(feet, inches)
window["output"].update(value=f"{result} m", text_color="white")
but they should be
try:
feet = float(values["feet"])
inches = float(values["inches"])
result = convert(feet, inches)
window["output"].update(value=f"{result} m", text_color="white")
except ValueError:
sg.popup("Please provide two numbers.", font=("Helvetica", 20))
We use an exception block here to display a popup window if a value error occurs.
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.
