seniornames =[]
paidornot =[]
for i in range("senior"):
print("Please enter the name of the Senior Citizen", i+1);
seniornames.append (input())
print(seniornames)
有错误说 - 文件“/ Users / rheasethi / Documents / Task 2 pre release.py”,第37行, 我在范围内(“高级”): TypeError:'str'对象不能解释为整数
我该怎么办?
答案 0 :(得分:0)
参数必须是普通整数。如果省略step参数, 默认为1.如果省略start参数,则默认为0.
从i+1
开始,你似乎需要我成为一个整数,所以也许你想要的是:
seniornames =[]
paidornot =[]
for i in range(len("senior")):
print("Please enter the name of the Senior Citizen", i+1)
seniornames.append (input())
print(seniornames)
或
for i in range(5):
print("Please enter the name of the Senior Citizen", i+1)
seniornames.append (input())
print(seniornames)