Both extend()
and append()
are methods used to add elements to a list in Python, but they behave differently.
append()
: This method is used to add a single element to the end of a list.
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]