When I tried something in Python, I encountered something strange:
a = [[1,2], [3,4]]
b = [x.append(5) for x in a]
It turns out b
is [None, None]
rather than [[1,2,5], [3,4,5]]
. I think it's related to the fact list is mutable, but not quite sure what exactly happens in this case. Could any of you explain? Thank you.