Join list

Difference between ʻappend and ʻextend used when you want to attach lists in python

append

a = [1,2]
a.append(3)
>>> [1,2,3]

a = [1,2]
a.append([1,2])
>>> [1,2,[1,2]]

extend

a = [1,2]
a.extend(3)
>>> [1,2,3]

a = [1,2]
a.extend([1,2])
>>> [1,2,1,2]

Recommended Posts

Join list
List comprehension
List comprehension
[Python] list
Join List elements without''. (Retrieve String from list without'')
Python basics: list
Color code list
List type, tuple type 2
list and sum
List type, tuple type
Python> Comprehension / Comprehension> List comprehension
List AWS ami
Note: List comprehension
Python list manipulation
List reverse operation