[Tutor] Help with elif

Ian Egland 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"
else:
    print("Sorry, you must enter either an F or a C. Case-sensitive. Please
try again."


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?

-Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090117/a89215c2/attachment.htm>


More information about the Tutor mailing list