0

I have seen somebody using [a, b] + [c, d] where i would have expected to use [a,b].extend([c,d]) or the use of append.

logically, it looks cleaner to use the + sign as opposed to a function (even if built-in).

I have looked into this and see comparisons between append and extend, but the limited mention of merely using the + sign.

Can someone explain what might be a convention or best practice (if there is one) or if there are differences in what they are?

Łukasz D. Tulikowski
  • 1,440
  • 1
  • 17
  • 36
D.L
  • 4,339
  • 5
  • 22
  • 45
  • Well, in the case of `[a, b] + [c, d]`, you are taking two lists, concatenating them, and creating a new list in the process. `extend` and `append` modify the list in-place. – Paul M. Nov 14 '19 at 23:06
  • I also see that `extend` behaves like `+=` in the associated similar questions which could be recursive (if calling itself) whereas `+` is not recursive. – D.L Nov 15 '19 at 00:54

0 Answers0