Python Idle在我的代码中标记了一个错误:行
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0)
6和之后突出显示冒号,说有语法错误。
如果您需要,它作为一个整体的功能是:
def clearPDoms(group,store):
for i in store:
removed.append(i[1])
for i in removed:
pos = getPos(i)
tbd = [pushPos(pos)]
ntbd = 1
if pos[2]==0:
if pos[1] != 0:
tbd.append(pushPos(pos[0],pos[1]-1,0)
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0)
if pos[0] != 0:
tbd.append(pushPos(pos[0]-1,pos[1],1))
tbd.append(pushPos(pos[0]-1,pos[1]+1,1))
if pos[0] != 6:
tbd.append(pushPos(pos[0]+1,pos[1],1))
tbd.append(pushPos(pos[0]+1,pos[1]+1,1))
else:
if pos[0] != 0:
tbd.append(pushPos(pos[0]-1,pos[1],1)
if pos[0] != 5:
tbd.append(pushPos(pos[0]+1,pos[1],1)
if pos[1] != 0:
tbd.append(pushPos(pos[0],pos[1]-1,0))
tbd.append(pushPos(pos[0]+1,pos[1]-1,0))
if pos[1] != 7:
tbd.append(pushPos(pos[0],pos[1]+1,0))
tbd.append(pushPos(pos[0]+1,pos[1]+1,0))
for i in tbd:
for j in range(0,len(group)-1):
if check(i,group[j][1]) == True:
del group[j]
非常感谢你的帮助。
答案 0 :(得分:2)
你的括号不均衡。你错过了一个结束的人:
而不是:
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0)
执行:
if pos[1] != 6:
tbd.append(pushPos(pos[0],pos[1]+1,0))
^