Concatenate two lists in Python
Problem description
How can I concatenate two lists in Python? In other words, how to combine two lists into one bigger list.
Problem solution
First way to do that is add one list to another using + operator:
list1 = [0,1,2,3,4]
list2 = [5,6,7,8,9]
combined_list = list1 + list2
print(combined_list) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
You can also modify first list using extend():
list1 = [0,1,2,3,4]
list2 = [5,6,7,8,9]
list1.extend(list2)
print(list1) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]