Junior — Middle
How can you insert a new element at the end of an existing list?
sobes.tech AI
Answer from AI
In Python, to add a new element to the end of a list, the append() method is used. It adds one element to the end of the list, modifying the original list.
Example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Outputs: [1, 2, 3, 4]