Joining Lists in Python
You can join two or more lists using the + operator or the extend() method.
Using + Operator
Example: Concatenating Lists
# Concatenating lists
list1 = ["Karthick AG", "Durai"]
list2 = ["Vijay", "John"]
combined_list = list1 + list2
print("Combined List:", combined_list)
Output
Combined List: ['Karthick AG', 'Durai', 'Vijay', 'John']
Explanation: The + operator concatenates the lists.
Using extend() Method
Example: Extending a List
# Using extend()
list1.extend(list2)
print("Extended List1:", list1)
Output
Extended List1: ['Karthick AG', 'Durai', 'Vijay', 'John']
Explanation: The extend() method adds the elements of list2 to the end of list1.