As a beginner in Python's Tkinter, I am trying to create an "Ultimate Fitness Calculator" on Tkinter for users to enter their weight, height, age and find out their BMR (basal metabolic rate) and TDEE (total daily energy expenditures). I've gotten most of the code down but I am stuck at debugging a certain part of an algorithm.
The problem is about converting a string to a float.
I'm confused because I've already written down all necessary global variables, and I thought W, H and A are already meant to be floats because I coded that way. For example, I said H = (float(Height_CM.get())), W = (float(Weight_KG.get())), and so on. Here is the bug:
line 53, in Q1d_Gender
BMR = (66 + (13.7*float(W)) + (5*float(H)) - (6.8*float(A)))
ValueError: could not convert string to float: 'w'
Also, I tested the algorithm above by simply printing statements to the console, like this:
W = input("enter weight")
H = input("enter height")
A = input("enter age")
BMR = (66 + (13.7*float(W)) + (5*float(H)) - (6.8*float(A)))
print(BMR)
And it worked. I don't understand why it won't work with the tkinter GUI.
Check out the full code for the tkinter, and copy and paste it to Pycharm or any Python program. Thanks for helping, and yes, I am a beginner :(