考虑以下代码:
def subir_norte(altitudes,inicio):
a3=altitudes[inicio[0]][inicio[1]]
a4=altitudes[j][inicio[1]]
p=[a,inicio[1]]
for j in range(inicio[0]-1,-1,-1):
while a4 < a3:
a=j+1
elif ((a4 >= a3) and j=0):
a=0
else subir_norte(altitudes,inicio)
return p
当我尝试运行该程序时,它在第七行显示“ SyntaxError:语法无效”。 我该如何解决?
答案 0 :(得分:0)
On this line
elif ((a4 >= a3) and j=0):
The j=0
should have a double equals as in python equality is written using two equals so it should be
elif ((a4 >= a3) and j==0):
on another note the brackets are not neccesary (but don't change anything) so you could write it as
elif a4 >= a3 and j == 0:
Another issue is that this elif is part of a while loop so it should either be part of and if statement or an if statement itself.