

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Introduction to Data Structures
incomplete
2: What Are Data Structures?
incomplete
3: Lists
incomplete
4: Lists Quiz
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
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.