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]

#pythonoddity

@treyhunner "There should be oneโ€“ and preferably only one โ€“obvious way to do it." -The Zen of Python

@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. ๐Ÿคท