Append vs. extend, when i use it?

Hello Developer,

I am checking out basics again.

I am used to create my methode “append.” I am able to collect unwrapped elements.
When use i the oposite - extend? does anybody have some practicale advantage?
2020-08-07_09h29_26

 arr = [1,2,3]
 too = ["OK!"]
 col = []
 next = []

 for x in arr:
   col.append(too)

 for x in arr:
   next.extend(too)

 OUT = col, next

KR

Andreas

append adds an object to a list, whereas extend concatenates the list.

1 Like