Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python concatenate lists

a = [1, 2, 3]
b = [4, 5]

# method 1:
c = a + b # forms a new list with all elements
print(c) # [1, 2, 3, 4, 5]

# method 2:
a.extend(b) # adds the elements of b into list a
print(a) # [1, 2, 3, 4, 5]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #concatenate #lists
ADD COMMENT
Topic
Name
3+1 =