
ValueError: could not convert string to float: '123 456'Īn alternative for getting the float values is asking for them in a popup window - this can be done with. > float('123 456') # no whitespace as separator

ValueError: could not convert string to float: '123,456' ValueError: could not convert string to float: 'no number' ValueError: could not convert string to float: Some examples > float('') # probably your case Most probably (if you didn't cut anything off your error message), you forgot to fill out one field and are thus trying to perform float('').

You should be able to convert strings that look like floats to floats by just using float(mystr). Probable cause: you forgot to fill out one field ExplanationĪ float can be constructed from a str, it just has to have the right format. I tried all the methods I found on the internet but nothing worked. Name_entry = Entry(root, font="System 12", relief=SUNKEN)īoygirle = Entry(root, font="System 12", relief=SUNKEN) Hello_lbl = Label(root, font="System 14")īoygirlq = Label(root, text="Are you a boy or a girl?", font="System 12 bold")īoy_kg = Label(root, text="Please enter your weight(in kg):", font="System 12 bold")īoy_cm = Label(root, text="Please enter your height(in cm):", font="System 12")īoy_age = Label(root, text="Please enter your age(in years):", font="System 12")ītn_cont = Button(root, text="Continue", font="Helvetica 12", command=BMI, relief=RAISED)īoy_kg_entry = Entry(root, font="System 12", relief=SUNKEN)īoy_cm_entry = Entry(root, font="System 12", relief=SUNKEN)īoy_age_entry = Entry(root, font="System 12", relief=SUNKEN) Name = Label(root, text="Please enter your name:", font="System 12") It tells you how many calories you have to eat!", font="System 14 bold")

Welcome = Label(root, text="Hello! This is a BMR calculator.
ERROR COULD NOT CONVERT STRING TO FLOAT HOW TO
I have to take input from an entry and I don't know how to convert that input(it's a string by default) into a float to start using the numbers.īMI = 66.5 + (13.75 * float(boykg)) + (5.003 * float(boycm)) - (6.755 * float(boyage))īmi_temp = Label(root, text="This is how many calories you have to eat if you have a non-active life: " + str(float(BMI)))
ERROR COULD NOT CONVERT STRING TO FLOAT CODE
Recently I have been working on a code and got stuck for days on this error.īasically the program calculates how many calories you have to eat everyday.
