list1 = [1, 2, 3] list2 = [4, 5, 6] concatenated_list = list1 + list2 # concatenated_list will be [1, 2, 3, 4, 5, 6]
In Python, you can concatenate two or more lists using the '+' operator.
Alternatively, you can use the extend() method to add the items of one list to another. For example:
list1 = [1, 2, 3] list2 = [4, 5, 6] list1.extend(list2) # list1 will be [1, 2, 3, 4, 5, 6]
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.