so i have been trying to get these two function to work, when i do them sepretly they work, but when i combine the two functions using the elif function, it only runs the 1st function and prints out position list, and an error says"the neighbour_list is not defined"
this is my code
my_file=open("test_graph_1.txt","r")
x=[]
y=[]
nodenumber=[]
positionx=[]
positiony=[]
for row in my_file:
value=row[:-1]
my_list=value.split(",")
if len(my_list)==3:
nodenumber.append(int(my_list[0]))
positionx.append(int(my_list[1]))
positiony.append(int(my_list[2]))
nodenumber1 =[(nodenumber[a],positionx[a],positiony[a]) for a i range(len(nodenumber))]
position_list=tuple(nodenumber1)
elif len(my_list)==2:
x.append(int(my_list[0]))
y.append(int(my_list[1]))
l1 = [(x[i] , y[i]) for i in range(len(x))]
l2 = [(y[i] , x[i]) for i in range(len(x))]
l1.extend(l2)
neighbour_list=[[l[0] for l in l1 if l[1] == j] for j in range(len(x))]
print("position_list",position_list)
print("neigh",neighbour_list)
but when i print the code the position list comes put fine but the neighbour_list comes out like this :[[4, 1], [0, 4, 2], [1, 3], [2, 5, 4], [3, 0, 1], [3], []] the extra empty string, which isn't suppose to be there but before that all is fine