Algorithm


 1. Initialize an empty list, result_list.

 2. Iterate over the elements in list1:
        2.1 Append each element to result_list.

 3. Iterate over the elements in list2:
        3.1 Append each element to result_list.

 4. Return result_list.

Code Examples

#1 Code Example- Python Programing Using + operator

Code - Python Programming

list_1 = [1, 'a']
list_2 = [3, 4, 5]

list_joined = list_1 + list_2
print(list_joined)
Copy The Code & Try With Live Editor

Output

x
+
cmd
[1, 'a', 3, 4, 5]

#2 Code Example- Python Programing Using iterable unpacking operator *

Code - Python Programming

list_1 = [1, 'a']
list_2 = range(2, 4)

list_joined = [*list_1, *list_2]
print(list_joined)
Copy The Code & Try With Live Editor

Output

x
+
cmd
[1, 'a', 2, 3]

#3 Code Example- Python Programing With unique values

Code - Python Programming

list_1 = [1, 'a']
list_2 = [1, 2, 3]

list_joined = list(set(list_1 + list_2))
print(list_joined)
Copy The Code & Try With Live Editor

Output

x
+
cmd
[1, 2, 3, 'a']

#4 Code Example- Python Programing Using extend()

Code - Python Programming

list_1 = [1, 'a']
list_2 = [1, 2, 3]

list_2.extend(list_1)
print(list_2)
Copy The Code & Try With Live Editor

Output

x
+
cmd
[1, 2, 3, 1, 'a']
Advertisements

Demonstration


Python Programing Example to Concatenate Two Lists-DevsEnv