ValueError: 0 is not in list

ValueError: 0 is not in list

我是 python 的新人。我对这段代码有一些问题,它是 project.List 的一部分 v、h、lx 与主要数据相似。错误在第 15 行:"ValueError: 0 is not in list"。我无法理解这个错误的原因解决this.Code如下。

v = [(0,5), (2,5), (3,2), (4,2), (5,5)]
h = [(5,0), (5,2), (2,3), (2,4), (5,5)]
lx = [(0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (2, 0), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 2), (4, 0), (4, 2), (5, 0), (5, 2), (5, 5)]
#ly= [(0, 0), (2, 0), (3, 0), (4, 0), (5, 0), (0, 2), (2, 2), (3, 2), (4, 2), (5, 2), (0, 3), (2, 3), (0, 4), (2, 4), (0, 5), (2, 5), (5, 5)]
ly = sorted(lx, key = lambda q : q[1])

for i in range(len(lx)):
    x0 = lx[i][0]
    y0 = lx[i][1]

    if((x0,y0) in v or (x0,y0) in h):
        continue
    else:
        for j in range(1, len(v)):
            x1 = ly[ly.index(x0, y0) + j][0] 
            if ((x1,y0) in v):
                continue
            else:
                pass

        for k in range(1, len(h)):      
            y1 = lx[lx.index(x0,y0) + k][1]
            if ((x0,y1) in h):
                continue
            else:
                pass    
    print(x0,y0,x1,y1)

错误:

Traceback (most recent call last):
  File "C:\Users\ASUS\Desktop\python\test2.py", line 15, in <module>
    x1 = ly[ly.index(x0, y0) + j][0] 
ValueError: 0 is not in list

预期输出:

0 0 2 2
0 2 2 3
0 3 2 4
0 4 2 5
.......

index((x0, y0)) 而不是 index(x0, y0)