I have a list of characters, and for each character I need to update a list based on the character. The list represents a 2D vector, and I would like to save each vector to a list to keep track of every iteration. If there are duplicates I dont need to worry about it, I just have to see which ones came up. So, here's what Im working with:
dir_list = [] #this list is populated by a txt file
vectors = []
main_vector = [1, 1]
for i in dir_list:
if(i == '^'):
main_vector[0] += 1
vectors.append(main_vector)
if(i == 'v'):
main_vector[0] -= 1
vectors.append(main_vector)
if(i == '>'):
main_vector[1] += 1
vectors.append(main_vector)
if(i == '<'):
main_vector[1] -= 1
vectors.append(main_vector)
print(main_vector)
print(vectors)
So the main_vector updates, and the vectors list gets the right number of entries, but theyre all the same - whatever main_vector ends up being. Ive tried appending differently, moving things around,