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]
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.