+ 1

Invalid elif syntax error

import string a = input() c = input() if str(c) == "lb": b = float(a) // float(0.454) print(str(b) + " kg") elif str(c) == "kg": b = float(a) * float(2.204) print (str(b) + " lb") does any body know why this is giving me an error

16th Nov 2016, 6:51 PM
Jacob Gibson
Jacob Gibson - avatar
1 Odpowiedź
+ 1
Because the indentation is very important in Python. Working code: a = input() c = input() if str(c) == "lb": b = float(a) // float(0.454) print(str(b) + " kg") elif str(c) == "kg": b = float(a) * float(2.204) print (str(b) + " lb")
16th Nov 2016, 7:40 PM
Vladimir Honcharenko
Vladimir Honcharenko - avatar