python - Celsius and Fahrenheit converting with choices -
i new python, , trying make python program choose if want convert fahrenheit celsius. here program:
x = (raw_input("would convert fahrenheit(f) or celsius(c)?")) if x == "f": y = (raw_input("what fahrenheit?")) f = (int(y) - 32) * 5.0 / 9 print f if x == "c": n = (raw_input("what celsius?")) z = (int(n) *9) / 5 + 32 print "and in fahrenheit, is:" print z i tried change if x == "c" elif x == "c", gave me texterror. ideas?
just indent print:
x = raw_input("would convert fahrenheit(f) or celsius(c)?") if x == "f": y = raw_input("what fahrenheit?") f = (int(y) - 32) * 5.0 / 9 print f elif x == "c": n = raw_input("what celsius?") z = (int(n) * 9) / 5.0 + 32 print "and in fahrenheit, is:" print z
Comments
Post a Comment