how to concat two lists in python code example
Example 1: python concatenate lists
a = [1, 2, 3]
b = [4, 5]
c = a + b
print(c)
a.extend(b)
print(a)
Example 2: how to combine two lists in python
listone = [1,2,3]
listtwo = [4,5,6]
joinedlist = listone + listtwo
Example 3: merge lists in list python
import itertools
a = [['a','b'], ['c']]
print(list(itertools.chain.from_iterable(a)))
Example 4: merge two lists python
>>> l1 = [1, 2, 3]
>>> l2 = [4, 5, 6]
>>> joined_list = [*l1, *l2]
>>> print(joined_list)
[1, 2, 3, 4, 5, 6]