You can add an item to the end of a list in Python using the append() method. Here’s an example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]
In this example, the number 4 is added to the end of my_list.
You can add an item to the end of a list in Python using the append() method. Here’s an example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]
In this example, the number 4 is added to the end of my_list.
0 Comments