我有一个使用weight_type.upper()
的解决方案,但我仍在学习,我想知道为什么[weight_type =='L'或'l':]没有给我正确的答案。
weight = input("What is your weight? ")
weight_type = input("Is it in (L)bs or (K)g? ")
if weight_type == 'L' or 'l':
print(f"Output weight in (K)g is {int(float(weight))*0.453592}")
elif weight_type == "K" or 'k':
print(f"Output weight in (L)bs is {int(float(weight))*2.20462}")
else:
print("Unsupported weight type")
结果:
What is your weight? 70
Is it in (L)bs or (K)g? k
Output weight in (K)g is 31.75144
Process finished with exit code 0