You may need a way to determine if the plane is empty of passengers (to ensure everyone has deboarded) or to see exactly how many passengers are on board. To do this, we can implement two methods: is_empty()
and size()
. These methods are also helpful in making sure we avoid calling our deque methods on an empty deque.
To determine if the deque is empty, we implement the is_empty()
method, which should:
- Return
True
if the deque is empty (has 0 items in theelements
list) orFalse
if the deque contains one or more elements.
To obtain the size of the deque, we implement the size()
method, which should:
- Return the length of the deque(the number of items in the
elements
list).
Instructions
Implement the is_empty()
method based on the above implementation details in Python.
Test calling the is_empty()
method and print out the returned value.
Implement the size()
method based on the above implementation details in Python.
Test calling the size()
method and print out the returned value.
Call the remove_first()
method and call both the is_empty()
and size()
methods again, printing out both returned values.