Modify a list using append(), remove(), and pop() list operations.
Search a list using a for loop.
Using list operations to modify a list
An append() operation is used to add an element to the end of a list. In programming, append means add to the end. A remove() operation removes the specified element from a list. A pop() operation removes the last item of a list.
Iterating lists
An iterative for loop can be used to iterate through a list. Alternatively, lists can be iterated using list indexes with a counting for loop. The animation below shows both ways of iterating a list.
Adapted from Introduction to Python Programming by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.
These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.