Please find the below code block in python 2.7.
for i in range(len(p_routes)):
if len(p_routes[i]) > 2 :
if p_routes[i][2] == 'No Backup':
K = K + 1
for z in range(len(p_routes[i])):
nbup.write(K + 1 , z , p_routes[i][z])
elif p_routes[i][0][0] == 'E' :
L = L + 1
for z in range(len(p_routes[i])):
ex.write(L, z , (p_routes[i][z])
elif p_routes[i][0][0] == 'G':
M = M + 1
for z in range(len(p_routes[i]))
gh.write(M ,z, p_routes[i][z])
else len(p_routes[i]) < 2:
pass
print "\nFor some reason. "
Well, I am getting an syntax error saying elif p_routes[i][0][0] == 'G': . I couldn't figure out why this error is coming as I believe there is no syntax error in this line.
The ex and gh are two excel sheet variable created before this code block. And p_routes is a list of list of 2 degrees. The format is like p_routes = [['prov1' , 'address1' , 'No Backup'] , ['prov2', 'address2', 'Back1', 'Back2' ]]
You might have understood, that the inner list length is a variable size. Any advise would be much appreciated. Sorry for the silly question but I did a lot of searching and re-formatting my if..else block in number of ways. But every time I am getting this error.
By the way previously the syntax error was with L = L + 1. Funny! Then I changed the type of L by L = int(L). Now, that error is gone.
elsestatement as well,elsedoesn't have a condition, it's what is done if all other conditions are false. Besides, bothpassand aprintstatement?ex.write(L, z , (p_routes[i][z])should be thisex.write(L, z , (p_routes[i][z]))and there are many other errors