list.pop and list.pop()
python - Pop() an element of a list in the list of lists - Stack Overflow
Difference between pop and remove
How do I pop multiple items from a queue? (python)
Videos
This feels like one of those python weird things. I am interested in explanations.
If I have a list=[1,2,3,4] and I do list.pop() the result is list=[1,2,3].
Perfect, just what I wanted.
However, if I am not careful and instead do list.pop--note there are no parentheses this time--I get no syntax error or warning and nothing happens, leading me to a strange debug session.
In the repl, if I do l.pop it just identifies it as a built-in method of list object at 0xwhatever. That's useful, but why is there not at least a runtime warning when I make this mistake in my code?
listoflists[1].pop(0)
listoflists[1] equals list2
so
listoflists[1].pop(0) equals list2.pop(0)
the correct way to pop 2d arrays is like this
list1=[1,2]
list2=[3,4]
listoflists=[list1, list2]
print listoflists
listoflists[0].pop(0)//correct way to pop
print listoflists
here is another post similar to yours on poping 2d lists that also might be of use.
Can someone explain me what the difference between pop and remove is that makes sense? Why would you use pop over remove or vice versa?
Thanks!