在第3行,名为temp_unit
的变量不被视为变量,并且显示无效语法。
temp = int(input("what is the Temperature?:")
temp_unit = input("Celcius or Farenheit?:")
if temp_unit == "C" or temp_unit=="c":
print("The given temperature in Fahrenheit is "+(9/5)*(temp+32))
else:
print("The given temperature in Celcius is "+(5/9)*(temp-32))
你需要添加括号,所以它应该是这样的:
temp=int(input("what is the Temperature?:"))
temp_unit= input("Celcius or Farenheit?:")
if temp_unit == "C" or temp_unit=="c":
print("The given temperature in Fahrenheit is "+(9/5)*(temp+32))
else:
print("The given temperature in Celcius is "+(5/9)*(temp-32))