作为一个项目,我目前正在编写一个配对系统。我目前正在代码的实际匹配部分。但是,我不断抛出“元组索引超出范围”错误。我已经看了很多遍了,但我似乎无法弄清楚到底出了什么问题。我所有的元组的长度都大于2,但是当我尝试在第117行中访问索引值1时,它将引发错误
UsersID = []
UsersAGE = []
UsersMUSIC = []
UsersGENDER = []
UsersLFG = []
UsersMAINT = []
#User ID
x = input('Enter lowest users I.D. number: ')
y = input('Enter highest users I.D. number: ')
for num in range(int(x),int(y)+1):
UsersID.append((num))
print(UsersID)
#User ID
#User AGE
Q = 0 + int(x)
while Q <= int(y):
Q += 1
q = input('Enter age: ')
UsersAGE.append(int(q))
print(UsersAGE)
#User AGE
#UserGENDER
W = 0 + int(x)
while W <= int(y):
W += 1
w = input('Enter gender: ')
UsersGENDER.append(w)
print(UsersGENDER)
#UserGENDER
#UsersLFG
E = 0 + int(x)
while E <= int(y):
E += 1
e = input('Enter LFG: ')
if e == "Indifferent/Doesn't matter":
UsersLFG.append('Female, Male, Non-binary, Agender, Intersex, Two-Spirt')
if e != "Indifferent/Doesn't matter":
UsersLFG.append(e)
print(UsersLFG)
#UsersLFG
#UsersMUSIC
R = 0 + int(x)
while R <= int(y):
R += 1
r = input('Enter Music type: ')
UsersMUSIC.append(r)
print(UsersMUSIC)
#UsersMUSIC
#UsersMA-INT
T = 0 + int(x)
while T <= int(y):
T += 1
t = input('Enter Main interests: ')
UsersMAINT.append(t)
print(UsersMAINT)
#UsersMA-INT
print('Loading........')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
print('---------------')
Users = []
ALA = 0
while ALA <= (int(y)-int(x)):
BLB = (UsersID[ALA],UsersAGE[ALA],UsersGENDER[ALA],UsersLFG[ALA],UsersMUSIC[ALA],UsersMAINT[ALA])
Users.extend([BLB])
ALA += 1
print(Users)
A13 = []
A14 = []
A15 = []
A16 = []
A17 = []
for user in Users:
if user[1] == 13:A13.append(user)
if user[1] == 14:A14.append(user)
if user[1] == 15:A15.append(user)
if user[1] == 16:A16.append(user)
if user[1] == 17:A17.append(user)
SORTEDUsers = A13 + A14 + A15 + A16 + A17
print('------')
print(A13)
print('------')
print(A14)
print('------')
print(A15)
print('------')
print(A16)
print('------')
print(A17)
print('------')
print(SORTEDUsers)
for person in A13:
SORTEDUsers.remove(person)
A13.remove(person)
for persons in SORTEDUsers:
if person[1] == (persons[1] + 1) or person[1] == (persons[1]) and (persons[2] in person[3]) and person[6] in persons[6]:
print(person[0],persons[0])
SORTEDUsers.remove(persons)
if persons in A13: A13.remove(persons)
if persons in A14: A14.remove(persons)
break
有人知道为什么我会抛出此错误吗?如果是这样,我该如何解决?错误正在第117行抛出