雷蒙德1962
艾米1982
杰克1978
凯文1970
罗莎1981
查尔斯1970
特里1968
吉娜1978
我必须创建一个程序,要求用户的名字,他们想知道的人的年龄。你知道吗
# Storing name information
names = ['Raymond', 'Amy', 'Jake', 'Kevin', 'Rosa', 'Charles', 'Terry', 'Gina']
# Assigning year of birth
YOB = ['1962', '1982', '1978', '1970', '1981', '1970', '1968', ',1978']
# Assigning each name in the form of a string to an integer value
Raymond = 1962
Amy = 1982
Jake = 1978
Kevin = 1970
Rosa = 1981
Charles = 1970
Terry = 1968
Gina = 1978
a = 2019
names = input('Who is the person you want to know the age of')
print('Their age is:', a - names)
这就是我目前所拥有的。你知道吗
Line 22: TypeError: unsupported operand type(s) for Sub: 'int' and 'str'.
这是我运行它时的错误消息
不能从int中减去字符串。此外,YOB列表包含字符串,而不是数字。你知道吗
为什么不用字典呢?你知道吗
相关问题 更多 >
编程相关推荐