I am struggling to pass a list (holder, which contains [0,0]) to another function. I want check_neighbours to pick up the list and then do some further processing. I think I am passing it correctly in main() but I am not sure what I must do to get the list to simply display its contents when called upon inside check_neighbours. I have tried a = holder but I received the error:
global name "holder" is not defined
I believe I must put holder = #something here but I cannot figure out what.
def create_matrix(file):
with open('network.txt') as f:
Alist = []
for line in f:
part = []
for x in line.split(','):
part.append(int(x))
Alist.append(part)
return Alist
def start_node(Alist):
i=0
j=0
#point node to pos [0][0] of Alist
node = Alist[i][j]
#create a list to hold co-ordinates
holder = []
holder.append(i)
holder.append(j)
print holder
return node, holder
#test neighbours to see if they can be used
def check_neighbours(node, Alist):
holder = #something
#code begins here
def main():
file = ("F:/media/KINGSTON/Networking/network.txt")
Alist = create_matrix(file)
node = start_node(Alist)
holder = check_neighbours(node, Alist)
main()