The flight has landed, and it’s time to deboard the passengers. When we remove a passenger from the front door of the plane, we must remove them from the front of the deque. To remove an item from the front of the deque, we need to use a remove_first() method to do so. This method will return the removed item, allowing us to use the popped item elsewhere in the code.

The remove_first() method should:

  • Pop the first (or rightmost) item from the elements list.
  • Return the popped item at the end of the method.

The time complexity of this method is O(1), constant time, since the Python method pop() has a runtime of O(1).



Implement the remove_first() method based on the above implementation details in Python.


Test calling the remove_first() method and set the returned value to a variable called popped_front.


Print the value of popped_front to verify that the item popped from the deque is value 20.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?