input:
ls = ['hi', 'bye', 'cya', 'hello', 'nope']
ls_popped = []
i = 0
while i < 3:
ls_popped.append(ls.pop(i))
i += 1
print(ls)
print(ls_popped)
output:
['bye', 'hello']
['hi', 'bye', 'nope']
expected output:
['hello', 'nope']
['hi', 'bye', 'cya']
i believe the pop function pops and returns the element at index i, so it should pop from i = 0 to 2 and return these elements to the new list. im not sure why this is not working as expected.