[Tutor] Help with elif
echolynx at gmail.com
Sun Jan 18 04:21:34 CET 2009
Wow, that was a quick response! Thanks all!
I have looked at a couple tutorials and whipped this up. However, attempting
to run it in IDLE results in a syntax error leaving my elif highlighted in
red. What's wrong? I've looked at the code and can't find any syntax errors-
though I've just started.
print("[Temperature Converter, First Edition]")
print("Created on January 17th, 2009 by Ian Egland")
temp1 = int(input("Please enter a temperature: "))
scale = input("Convert to (F)ahrenheit or (C)elcius?")
if scale == "F":
temp2 = (9/5)*temp1+32
print(temp1, "C =", temp2, "F"
elif scale == "C": # Error appears here.
temp2 = (5/9)*(temp1-32)
print(temp1, "F =", temp2, "C"
print("Sorry, you must enter either an F or a C. Case-sensitive. Please
In regards to learning python, I've found that after I get somewhat-familiar
with a language, I want a programming problem to solve with what I've
learned. While learning Java, http://www.javabat.com has been my best
friend. (That is, as close to a best friend as programming website can be.)
Is there something like this for Java? Is one in the works?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor