Exercise: Collecting Your Thoughts About collections

Here’s a silly exercise for today. Create a list of 1000 random numbers between -100 and 100.

Use this list to create a deque with the same 500,000 numbers.

Part 1

Now, write a function that empties the list from the right. So, create a loop that takes out the last item from the list until the list is empty.

Write another function or modify the first one to empty the list from the left. So, you’ll remove the first item from the list repeatedly until the list is empty.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

You must own this product to join the conversation.