Reputation: 251
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."
Upvotes: 1
Views: 231
Reputation: 133514
You forgot the colon (:
) after the last else
.
Also:
input ("Convert to Celsius or Fahrenheit?")
should be changed to
raw_input ("Convert to Celsius or Fahrenheit?")
as input()
tries to evaluate its input while raw_input
takes a 'raw' string. When you enter c
for example into the input()
it tries to evaluate the expression c
as if it were python code which looks for a variable c
whereas raw_input
simply 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 output
is a number.
Change it to
print "That's " + str(output) + " degrees Celsius!"
or
print "That's %d degrees Celsius!" % output
Upvotes: 9