I’m getting a syntax error on the last line – line 14. I can’t see why though, as it seems to be a simple print statement.
cel = "c"
far = "f"
cdegrees = 0
fdegrees = 0
temp_system = input ("Convert to Celsius or Fahrenheit?")
if temp_system == cel:
cdegrees = input ("How many degrees Fahrenheit to convert to Celsius?")
output = 5/9 * (fdegrees - 32)
print "That's " + output + " degrees Celsius!"
elif temp_system == far:
fdegrees = input ("How many degrees Celsius to convert to Fahrenheit?")
output = (32 - 5/9) / cdegrees
print "That's " + output + " degrees Fahrenheit!"
else print "I'm not following your banter old chap. Please try again."
You forgot the colon (
:) after the lastelse.Also:
should be changed to
as
input()tries to evaluate its input whileraw_inputtakes a ‘raw’ string. When you entercfor example into theinput()it tries to evaluate the expressioncas if it were python code which looks for a variablecwhereasraw_inputsimply takes the string without attempting to evaluate it.Also you cannot concatenate(add together) strings with integers as you are doing in this case where
outputis a number.Change it to
or