Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Newbie with syntax error that I cant figure out
-
I have been coding for just one month and hate to trouble everyone with this but getting syntax error on the ibw_man and ibw_woman functions. I cant figure out why after exhaustive effort. Any help would be appreciated.
"""Bariatric Math Calculations""" weight_lbs = int(raw_input('what is your current weight (lbs): ')) height_ft = int(raw_input('what is your current height in feet: ')) height_inches = int(raw_input('You are ' + str(height_ft) + ' feet and how many inches: ')) previous_bariatrics = 0 def Weight_Convert_Kg(weight_lbs): x = weight_lbs / 2.204 return x weight_kg = int(Weight_Convert_Kg(weight_lbs)) def Total_Height_Inches(height_ft, height_inches): x = (height_ft * 12) + height_inches return x total_height_inches = int(Total_Height_Inches(height_ft, height_inches)) def Height_Convert_Meters(total_height_inches): x = total_height_inches * 0.0254 return x height_meters = Height_Convert_Meters(total_height_inches) height_meters = round(height_meters, 2) def Calc_Bmi(weight_kg, height_meters): x = weight_kg / (height_meters ** 2) return x BMI = int(Calc_Bmi(weight_kg, height_meters)) def Weight_Convert_lbs(weight_kg): x = weight_kg * 2.204 return x calc_weight_lbs = int(Weight_Convert_lbs(weight_kg) def Ibw_man (total_height_inches): x = 50 + (2.3 *(total_height_inches - 60)) return x ideal_body_wt_man = int(Ibw_man((total_height_inches)) * 2.204 def Ibw_woman(total_height_inches): x = 45.5 + (2.3 *(total_height_inches - 60)) return x ideal_body_wt_woman = int(Ibw_woman((total_height_inches)) * 2.204 print("kg: ", weight_kg) print("inches: ", total_height_inches) print("meters: ", height_meters) print("bmi: ", BMI) print("IBWm: ", ideal_body_wt_man) print("IBWw: ", ideal_body_wt_woman)
-
"""Bariatric Math Calculations""" try: raw_input except NameError: # Python 3 raw_input = input weight_lbs = int(raw_input('what is your current weight (lbs): ')) height_ft = int(raw_input('what is your current height in feet: ')) height_inches = int(raw_input('You are ' + str(height_ft) + ' feet and how many inches: ')) previous_bariatrics = 0 def Weight_Convert_Kg(weight_lbs): x = weight_lbs / 2.204 return x weight_kg = int(Weight_Convert_Kg(weight_lbs)) def Total_Height_Inches(height_ft, height_inches): x = (height_ft * 12) + height_inches return x total_height_inches = int(Total_Height_Inches(height_ft, height_inches)) def Height_Convert_Meters(total_height_inches): x = total_height_inches * 0.0254 return x height_meters = Height_Convert_Meters(total_height_inches) height_meters = round(height_meters, 2) def Calc_Bmi(weight_kg, height_meters): x = weight_kg / (height_meters ** 2) return x BMI = int(Calc_Bmi(weight_kg, height_meters)) def Weight_Convert_lbs(weight_kg): x = weight_kg * 2.204 return x calc_weight_lbs = int(Weight_Convert_lbs(weight_kg)) def Ibw_man (total_height_inches): x = 50 + (2.3 *(total_height_inches - 60)) return x ideal_body_wt_man = int(Ibw_man(total_height_inches) * 2.204) def Ibw_woman(total_height_inches): x = 45.5 + (2.3 *(total_height_inches - 60)) return x ideal_body_wt_woman = int(Ibw_woman(total_height_inches) * 2.204) print("kg: ", weight_kg) print("inches: ", total_height_inches) print("meters: ", height_meters) print("bmi: ", BMI) print("IBWm: ", ideal_body_wt_man) print("IBWw: ", ideal_body_wt_woman)
-
@danaportenier said: if @ccc’s suggestion did not fix it, please share the actual syntax error.
-
There were several problems of unpaired parentheses, corrected by @ccc code
Example just to explain: missing ) at end of line gives a syntax error on next linecalc_weight_lbs = int(Weight_Convert_lbs(weight_kg))
-
Thank you all. I’m embarrassed it was parentheses but guess I dont have a trained enough eye yet