During the multimedia class, we continue from the python lesson from last term, but for this session we are learning about python list. To learn that, we need to understand what is list to python. List is basically a collection of items that is ordered and changeable, written in square bracket and also allow to duplicate the items. Accessing Items is like to reach to one specific items that you want. Also, remember that the computer always count from zero. For example:
thislist = [“Ant”, “Bear”, “Cat”]
print (thislist[1])
Once this code activate, it will print “Bear” because as I mention before python start to count from zero so “Ant” is zero, “Bear” is one and “Cat” is two. Also the word that are in the list is called “index”. We also can change the index in the code from “Bear” to “Elephant”. In class we called that a change the items value. For instance:
thislist = [“Ant”, “Bear”, “Cat”]
thislist[1] = “Elephant”
print (thislist)
This code will print “Ant”, “Elephant”, “Cat” because in the python code, it tell to change from “Bear” to “Elephant”. Once you print it, you will see it like this: “Ant”, “Bear “Cat”, but you want it to be like a checklist so you can use this code to make it become like a checklist:
thislist = [“Ant”, “Bear”, “Cat”]
for x in thislist:
print(x)
After you do it, you will see it print:
Ant
Bear
Cat
These are some of the functions that use in the python list. There are more that we can use such as how to check if the items exist, list length, Append, Insert and Remove items. Also, there is a python dictionaries, but I only write about the Python list. To learn this code, it is really challenging for me because as I am not a native English speaker and now I have to learn more about computer language.