1# Basic syntax:
2first_list.append(second_list) # Append adds the the second_list as an
3# element to the first_list
4first_list.extend(second_list) # Extend combines the elements of the
5# first_list and the second_list
6
7# Note, both append and extend modify the first_list in place
8
9# Example usage for append:
10first_list = [1, 2, 3, 4, 5]
11second_list = [6, 7, 8, 9]
12first_list.append(second_list)
13print(first_list)
14--> [1, 2, 3, 4, 5, [6, 7, 8, 9]]
15
16# Example usage for extend:
17first_list = [1, 2, 3, 4, 5]
18second_list = [6, 7, 8, 9]
19first_list.extend(second_list)
20print(first_list)
21--> [1, 2, 3, 4, 5, 6, 7, 8, 9]
1list1 = ["a", "b" , "c"]
2list2 = [1, 2, 3]
3
4list1.extend(list2)
5print(list1)
6
1list1 = [1, 2, 3]
2list2 = [4, 5, 6]
3sum_list = []
4
5for (item1, item2) in zip(list1, list2):
6 sum_list.append(item1 + item2)
7
8print(sum_list)
1first_list = ["1", "2"]
2second_list = ["3", "4"]
3
4# Multiple ways to do this:
5first_list += second_list
6first_list = first_list + second_list
7first_list.extend(second_list)
8
1# Makes list1 longer by appending the elements of list2 at the end.
2list1.extend(list2)
3
1list1 = ["M", "na", "i", "Ke"]
2list2 = ["y", "me", "s", "lly"]
3list3 = [i + j for i, j in zip(list1, list2)]
4print(list3)
5# My name is Kelly