In a list, items can hold anything (for example strings, or numbers).
To declare a list, we declared comma separated items inside square brackets for example like below.
The example above is a list that has the number 1 as the first item, the string "two" as the second item, the number 3 as the third item and the number 4 as the fourth item.
we can declare a variable and set it to hold a list like below
my_list = [1,"two",3,4]
Now to refer to the 1st item (because in Python indexes start at zero), we just have to write:
There are some functions that we can use to manipulate (add/delete items from) a list. The function/method to add an item to end of list is called append, for example
will add an item that is the number 5 to the end of list.
The function/method to delete an item at a certain index in the list is called del, for example
will delete the item at index 1 (which is the 2nd item) from my_list.
To play with what you've learned in this lesson, go here
Next Lesson: Ranges and For Loops in Python Previous Lesson: Numbers in Python