How do you differentiate between append() and extend()?

The append() method is used to add an element to the end of a list in Python. When called on a list, it appends the element to the end of the list and does not modify the original list in any other way. This method can be used to add a single element or multiple elements to the end of a list. It is important to note that the append() method does not return a new list, but rather modifies the original list in place.

Example:

The extend() method adds elements from an iterable (such as a list or a tuple) to the end of the list. The elements are added in the order in which they appear in the iterable. For example, if you have a list [1, 2, 3] and you want to add the elements [4, 5] to the end of it, you can use the extend() method like this: [1, 2, 3].extend([4, 5]), which will result in the list [1, 2, 3, 4, 5].

Example: