无法调试超出范围的列表索引

2024-10-03 23:27:07 发布

您现在位置:Python中文网/ 问答频道 /正文

for i in range (len(userCards)):
  print("i is "+str(userCards[i]))
  if userCards.count(userCards[i]) == 4:
    userMatches = userMatches + 1
    userCards.remove(userCards[i])

我试图从一个数字列表中删除重复的卡片,但是我总是得到列表索引超出范围的错误


Tags: in列表forlenifiscountrange