I have a list queue
and an iterator object neighbors
whose elements I want to append to the list.
queue = [1]
neighbor = T.neighbors(1) #neighbor is a <dict_keyiterator at 0x16843d03368>
print(list(neighbor)) #Output: [2, 3]
queue.extend([n for n in neighbor])
print(queue)
Output:
[1]
Expected Output:
[1, 2, 3]
What is going wrong?