GH avatar Bite 45. Keep a queue of last n items

How about writing a queue that holds the last 5 items?

Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first. A real-world example of queue can be a single-lane one-way road, where the vehicle enters first, exits first. More real-world examples can be seen as queues at the ticket windows and bus-stops. [source]

Complete the my_queue function to return a queue-like data type that keeps the last n items.

Check the standard library to see how you can do this in the shortest/most efficient way.

See an example output below and the tests that check for various values of n. Have fun!

107 out of 112 users completed this Bite.
Will you be Pythonista #108 to crack this Bite?
It takes an average of ~34 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 3.2 on a 1-10 difficulty scale.
» You can do it! 😌

Login and get coding
We use Python 3.7