flâneur — a map of the web's best reading

5. Data Structures — Python 3.10.7 documentation

docs.python.org · 4,736 words · saved by 1 readers

This chapter describes some things you’ve learned about already in more detail, and adds some new things as well. The list data type has some more methods. Here are all of the methods of list objects: Add an item to the end of the list. Equivalent to a[len(a):] = [x]. Extend the list by appending all the items from the iterable. Equivalent to a[len(a):] = iterable. Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, and a.insert(len(a), x) is equivalent to a.append(x). Remove the first item from the list whose value is equal to x. It raises a ValueError if there is no such item. Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You

5. Data Structures — Python 3.14.6 documentation Navigation index modules | next | previous | Python » 3.14.6 Documentation » The Python Tutorial » 5. Data Structures | Theme Auto Light Dark | 5. Data Structures ¶ This chapter describes some things you’ve learned about already in more detail, and adds some new things as well. 5.1. More on Lists ¶ The list data type has some more methods. Here are all of the methods of list objects: list. append ( value , / ) Add an item to the end of the list. Similar to a[len(a):] = [x] . list. extend ( iterable , / ) Extend the list by a

Explore this link on the map →

related reading