In order to store a set of variable, we use a list.
A list can be illustrated as a box queue in a line, and we add our value to each box.
The box can be accessed using the box position. We would call it index.
In python index should start from 0.
So, first element is in index 0, second element is in index 1.. and so on.
We add an element to a list by .append(new value). myList.append("newValue")
We will be able to access an element by []
Let us have a list name myList, to get the first element, we will use myList[], second element, myList[1] and so on.
To remove an element from a list, use .pop(index).
To remove the first element, I use myList.pop(0)
To get the first element of a list and remove it, I use removelement = myList.pop(0)
Please do refer to the example below for better understanding on how to add element to a list , access the element of list. remove an element from a list.
There is another question regarding list.
Encyclopedia question
Subscribe to:
Post Comments (Atom)
Superior of partial fraction
What is complex fraction? Complex fraction is a fraction whereby its numerator or denominator or both consists of fractions. Partial frac...
-
What is fraction? Imagining you have one whole cake and you need to share the cake among you and your friends. Here come the problems, t...
-
This is a question that challenge your understand skill and programming skill. The Tremendous Tak-Tak Tree Output File: taktakout.txt T...
-
After a quite a long and challenging journey, we finally finish the training on Intermediate level book 1 to book 8. What a relieve huh ? ...
No comments:
Post a Comment