Why does the dequeue method not have a return statement when the queue is empty?


#1

Question

In this exercise, the dequeue() method does not have a return statement as part of Step 3. What happens in the case?

Answer

When the queue is empty, there is obviously nothing to return. However, even if no return statement is explicitly used in the code, there is an implicit return from the function. All Python functions have an implicit return value of None. In the case of Step 3, the code which calls dequeue() will receive the None as the return value.