我正在研究一种测量转换器。我通过整个代码与if
和elif
合作,但现在我从Invalid Syntax
获得了elif
。
elif original_measure == "inches":
if new_measure == "meters":
print(number, "inches =", number * 0.0254, "meters"
elif new_measure == "kilometers":
print(number, "inches =", number * 2.54e-5, "kilometers")
elif new_measure == "centimeters":
print(number, "inches =", number * 2.54, "centimeters")
elif new_measure == "miles":
print(number, "inches =", number * 1.5783e-5, "miles")
elif new_measure == "feet":
print(number, "inches =", number * 0.0833333, "feet")
elif new_measure == "yards":
print(number, "inches =", number * 0.0277778, "yards")
else:
print("'", new_measure, "'", "is an unknown new measure")
第一个elif
,elif new_measure == "kilometers":
获取无效语法。
答案 0 :(得分:1)
您错过了第一个)
的结束print
。