Original intent was to create a "list pop" mechanism to yield values based on the size of the list; ie, a self-depleting list. Did not get expected behavior, but would like to know what is going on behind the scenes.
Did not see anything even remotely close to my problem, and perhaps there is already an answer, but I don't even know what category of question this is. Many of the suggested solutions offered by stackoverflow.com were irrelevant. Bug or feature?
>>> ab = []
>>> for i in range(10):
ab.append(i)
>>> ab
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> def list_split(lst):
ni = []
for item in lst:
ni.append(lst.pop(0))
return ni
>>> ab
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> bc = list_split(ab)
>>> ab
[5, 6, 7, 8, 9]
>>> bc
[0, 1, 2, 3, 4]
What I had intended to happen was have ab spill its contents into bc, while keeping the order by forcing it to pop an item at index 0. As you can see, it apparently splits the list into two, giving the first half of the old list to the new list.
How does this have something to do with the indexing of the list, for a count of items in the list?