Python List Methods - Code Examples to Add Insert Remove Sort and Reverse Lists - APPFICIAL

Опубликовано: 22 Март 2026
на канале: Appficial
1,229
11

A list method does useful operation on a list such as adding elements, removing elements, sorting, reversing, and more.

list.append(item) - Add an item to the end of the list
list.extend([items]) - Add all items in [items] to the list
list.insert(i, item) - Insert item into the list before position i
list.remove(item) - Remove first occurrence of item from the list
list.pop() - Remove and return last item in the list
list.pop(i) - Remove and return item at position i from the list
list.sort() - Sort the items in the list, ascending
list.reverse() - Reverses the items in the list
list.index(item) - Return the index of the item’s first occurrence
list.count(item) - Counts the number of occurrences of item in the list

Note: The sorted() method returns an all new list that is sorted, rather than updating the original list

Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!