Python Program to Concatenate Two Lists

To understand this example, you should have the knowledge of the following Python programming topics:


Example 1: Using + operator

Output

[1, 'a', 3, 4, 5]

In this example, + operator is used to concatenate two lists.


Example 2: Using iterable unpacking operator *

Output

[1, 'a', 2, 3]

* operator allows unpacking inside the list or tuple.


Example 3: With unique values

Output

[1, 2, 3, 'a']

If you want the unique items from a concatenated list, you can use list() and set(). set() selects the unique values and list() converts the set into list.


Example 4: Using extend()

Output

[1, 2, 3, 1, 'a']

Using extend(), you can concatenate a list to another list as shown in example above.