How does `.pop()` work?

I don’t understand very well why the second gives an error, so I was researching about that and the only answer that I have is this maybe an action must be put after .pop() method, for example I tried print() function and the program ran very well

.pop() , removes a value from the list and returns it. This means that the original list is reduced in length.

In this example they asked us to move students from the all_students list to the students_in_poetry.

a simple code for this exercise would be:


while len(students_in_poetry) < 6:
students_in_poetry.append(all_students.pop())


.pop(index) if you dont give it a index, it asumes -1 taking the last value of the list