with this code that ive written, im not sure why its not outputting a value for the BMI..

can anyone help??


def application(environ, start_response):

    headers = [('content-type', 'text/html')]
    start_response('200 OK', headers)

    formdata = cgi.FieldStorage(environ=environ, fp=environ['wsgi.input'])

    if formdata.has_key('Mass') and formdata.has_key('Height'):
        Mass = float(formdata.getvalue('Mass'))
        Height = float(formdata.getvalue('Height'))
        BMI = formdata.getvalue('Mass/(Height*Height)')
        forminfo = "<p>Mass= %s, Height=%s, BMI=%s</p>" % (Mass, Height, BMI)
        forminfo = "no data input" 

    page = ["<html>", BMI_form, forminfo, "</html>"]

    return page

Edited 2 Years Ago by pyTony: format fixing

i found the problem.

but when i changed the BMI = formdata.getvalue('MAss/(Height*height)')

to BMI = (mass/height*height)

the value is wierd..
if i put 50kg and 150cm

which should be 22

or 60kg and 170cm
its 0.00207612456747


ive tried using float infront still doesnt change.. umm ive multipled it by 100, 1000...

no difference its still wierd.


wait dont worry....

about that..

but if i wanted to get it to a whole number like 22 or 20.8

how would i do that?

This article has been dead for over six months. Start a new discussion instead.