变量输入无效,如何将用户输入用于变量?

时间:2018-10-24 15:47:53

标签: python variables

我的代码:

birthYear = input("When were you born?")
thisYear = 2018
hippoSpan = 50
pabloSpan = 1881

print("You were born in " + str(birthYear) + " and currently it is 2018.")

print("")

print("You are " + str(thisYear - birthYear) + " years old.")
print("If you were a hippo, you would have " + str(hippoSpan - birthYear) + " years left to live.")
print("Pablo Picasso is " + str(pabloSpan - birthYear) + " years older than you.")

我不确定我在这里做错了什么,但是我试图让用户输入到变量中,因此用户将其输入为birthYear,然后可以使用它减去来自thisYear。请指出任何错误。

0 个答案:

没有答案