Let\'s say I have these assignments:
points = []
point = (1, 2)
How come when I do this:
points += point
The difference, is that list +=
is equivalent to list.extend()
, which takes any iterable and extends the list, it works as a tuple is an iterable. (And extends the list in-place).
On the other hand, the second assigns a new list to points
, and attempts to concatenate a list to a tuple, which isn't done as it's unclear what the expected results is (list or tuple?).