Okay, we know what lists are, but from a data structures and algorithms perspective, what are they good for? Let's break it down by operation:
cars.append("ford") is (on average) O(1). We go directly to the end and add the element.cars[2] is O(1). We go directly to the index and return the element.cars.pop(2) is O(n). We have to shift all the elements after the deleted element down one index.cars.index("ford") is O(n). We have to iterate over the list until we find the element.In other words, lists start to struggle in two primary areas:
We need to display a user's last job title on their profile.
Implement the last_work_experience function. It takes a list of our user's work history (strings) and returns the last place they worked.
None.