How to concatenate two lists in python?

A list is a data-structure, or it can be considered a container that can be used to store multiple data at once. The list will be ordered and there will be a definite count of it.
Here we’ll see some examples to concatenate lists in python.
e.g., using ‘+’ sign
l1=[1, 2, 3, 4, 5] l2=[6, 7, 8, 9, 10] l3=l1+l2 print(l3)

e.g., using extend function.
l1=[1, 2, 3, 4, 5] l2=[6, 7, 8, 9] l1.extend(l2) print(l1)

e.g., using ‘*’ operator
t1 = [1, 4, 5, 6, 5] t2 = [3, 5, 7, 2, 5] t = [*t1, *t2] print (t)

This is all about list concatenation in python.
Subscribe
Login
Please login to comment
0 Discussion