Python上的索引器不清晰

Python上的索引器不清晰,python,python-2.7,runtime-error,Python,Python 2.7,Runtime Error,请告诉我: T1 = ["me", "gusta", "espanol"]; T2 = ["si", "no", "espanol"]; scan_for_match(T1, T2) 如果T1[i]==T2[j]: 这对我来说毫无意义,因为: Traceback (most recent call last): File "stdin", line 1, in module File "stdin", line 5, in scan_for_match IndexError: list

请告诉我:

T1 = ["me", "gusta", "espanol"]; T2 = ["si", "no", "espanol"]; scan_for_match(T1, T2)
如果T1[i]==T2[j]: 这对我来说毫无意义,因为:

Traceback (most recent call last):
  File "stdin", line 1, in module
  File "stdin", line 5, in scan_for_match
IndexError: list index out of range

因此,这应该只是返回一个假结果,而不是索引器,对吗?

while
上的条件更改为:

i = 0
j = 0
T1[i] = 'me'
T2[j] = 'si'
而i

i=len(T1)
并且您尝试为列表编制索引时,您将得到一个
索引器,因为您的索引从零开始计数。

谢谢您的回答answer@CaioFleury我建议不要使用
pop()
方法。它将从列表中删除元素
i = 0
j = 0
T1[i] = 'me'
T2[j] = 'si'
while i < len(T1)
#       ^
>>> t2= ["si", "no", "espanol"]
>>> t1=  ["me", "gusta", "espanol"]
>>> set(t2) & set(t1)
{'espanol'}