0
Trying to do a temperature convertor
I'm trying to do a temperature convertor but I can't understand e fix this error. Can someone help me out with it? Tried to put the inputs out of the If Statement, but it doesn't go on. #The Code scale = input('Which scale do you want to use? ') if scale == c2f: c_f = float(input('Type the value in Celsius: ')) f = (c2f * 1.8) + 32 print('The temperature is', f, 'Fahrenheit.') elif scale == f2c: f2c = float(input('Type the value in Fahrenheit: ')) c = (f2c - 32) / 1.8 print('The temperature is', c, 'Celsius') print(scale)
2 odpowiedzi
+ 3
You need to use quotes as you are comparing the scale input as a string.
# Code
scale = input('Which scale do you want to use? ')
if scale == "c2f": # I added quotes here
c_f = float(input('Type the value in Celsius: '))
f = (c_f * 1.8) + 32
print('The temperature is', f, 'Fahrenheit.')
elif scale == "f2c": # I added quotes here
f_c = float(input('Type the value in Fahrenheit: '))
c = (f_c - 32) / 1.8
print('The temperature is', c, 'Celsius')
+ 1
NO WAY, MAN!
Little things we don't see.
Thanks a lot!