Extending a list in #Python
>>> a = []
>>> a.extend([2, 1]) # neat
>>> a += [3, 4] # hmm ok
>>> a += (7, 11) # huh?
>>> a[-1:] += [18, 29] # uh oh
>>> a[:] = [*a, 47, 76] # ๐ฆ
>>> a
[2, 1, 3, 4, 7, 11, 18, 29, 47, 76]
Extending a list in #Python
>>> a = []
>>> a.extend([2, 1]) # neat
>>> a += [3, 4] # hmm ok
>>> a += (7, 11) # huh?
>>> a[-1:] += [18, 29] # uh oh
>>> a[:] = [*a, 47, 76] # ๐ฆ
>>> a
[2, 1, 3, 4, 7, 11, 18, 29, 47, 76]
@peterdrake Exactly what I had in mind when sharing that. ๐
Though in this case I'd say there's approximately two obvious ways to do it.
a.extend([2, 1])
And
a += [2, 1]
Which I use depends on what the surrounding code looks like and the whim of the moment. ๐คท