Lists

I have given a pretty thorough explanation of lists and their handling on YouTube, so I highly recommend taking a look at the video before you head into the text.

Now, coming to the question I asked at the end of this video, how to empty the whole list?

We saw how we can pick up a section of a list and set it to blank in order to eliminate it. So, for this, let's do the exact same thing, but instead of taking a section of the list, we take the whole list.

numbers = [1, 2, 4, 6, 8]

numbers[:] = []

print(numbers)

Try running this code in the IDE below:

This sets the list numbers to a blank list.

Remember, the variable numbers still exists and is a list. Only the elements in the list have been erased, not the list itself.

Okay that's it for this tutorial. Be sure to comment any questions you may have on YouTube (or if you're feeling fancy, drop us an email)

Cya!