[Tutor] BMI Question
alan.gauld at btinternet.com
Tue Sep 25 01:13:09 CEST 2012
On 24/09/12 20:13, Aija Thompson wrote:
> So I've been working on this question for hours! And Python keeps giving
> me an error saying that my syntax for BMI is wrong. I really can't
> understand why.
So send us the full error text not a summary.
If Python reports a syntax its usually recorded at the point immediately
after the error so you may have to look at the line before.
> So this is what I have so far:
> w = raw_input('Please give your weight in lbs: ')
> h = raw_input('Now your height in feet and inches: ')
> h. split("'")
> ft, inches = h. split("'")
> h_sum = float(12*int(ft)) + (int(inches.strip('"'))
count the parens in the last expression...
> BMI = float(703*w)/float(h_sum*h_sum)
> print 'Your BMI is: ', BMI
Author of the Learn to Program web site
More information about the Tutor