Example 1: python append vs extend
my_list = [23, 11, 42, 24523]
my_list.append([34523, 76979])
print(my_list)
my_list.extend([12, 99])
print(my_list)
"""
Output:
[23, 11, 42, 24523, [34523, 76979]]
[23, 11, 42, 24523, [34523, 76979], 12, 99]
"""
Example 2: python how to add one list to another list
first_list.append(second_list)
first_list.extend(second_list)
first_list = [1, 2, 3, 4, 5]
second_list = [6, 7, 8, 9]
first_list.append(second_list)
print(first_list)
--> [1, 2, 3, 4, 5, [6, 7, 8, 9]]
first_list = [1, 2, 3, 4, 5]
second_list = [6, 7, 8, 9]
first_list.extend(second_list)
print(first_list)
--> [1, 2, 3, 4, 5, 6, 7, 8, 9]