Creation and use of lists in Python

Here’s a very basic example of a list and a bit of what you can do with it.

Creation and use of lists in Python

You can see the entire list when you print it, but you can also choose which of the elements inside the list you want to show by setting a range (exclusive). Always remember the lists starts off by 0, so if you wanted to only show the last three colors you’d need to set the range from 2 to 5.

Creation and use of lists in Python

Also, you can delete certain elements from the list, so no matter what range or whether or not you want to print the entire list, the element you’re deleting will not be shown.

Creation and use of lists in Python

CC BY 4.0 Creation and use of lists in Python by tywins is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.