我正在玩Python3。我希望weight
成为一个int,但我不知道我做错了什么。
age = input("How old are you? ")
height = input("How tall are you? ")
#Since I want to play around, I just want to Turn KG to LBS
#Below is where I'm stuck
weight = int(round(input("How much do you weight? ")*2.2046))
print(f"so you are {age} old, {height} tall and {weight}LBS heavy")
提前致谢。
答案 0 :(得分:3)
您必须首先将输入(string
)转换为int
/ float
,然后才能对其进行数字操作(*
)。< / p>
即
weight = round(int(input("How much do you weight? "))*2.2046)
注意首先评估int(input('...weight?'))
,然后评估*2.2046
部分,最后评估round()
。