how to append list to list in python code example
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: how to add an item to a list in python
myList = [1, 2, 3]
myList.append(4)
Example 3: python how to append to a list
your_list.append('element_to_append')
your_list = ['a', 'b']
your_list.append('c')
print(your_list)
--> ['a', 'b', 'c']
your_list = your_list.append('c')
Example 4: append to lists python
list = ['a', 'b', 'c', 'd']
print list[1:-1]
list[0:2] = 'z'
print list
Example 5: opython append list
list.append(item)