Python Diary - 10/08/2018 (Python starts from 10/04/2018)
1. List: Lists are a datatype you can use to store a collection of different pieces of information as a sequence under a single variable name.
(Other datatypes: strings, numbers, and booleans.)
List_name = [item_1, item_2]
2. A list doesn't have to have a fixed length. You can add items to the end of a list any time you like!
list_name.append("add item")
3. List Slicing: access a portion of a list
slice = list_name[1:4] (slice equals to the second, third and forth items in list_name)
NOTE: The fifth item is not included!
list_name[2:] means from index 2(the third item) to the end.
list_name[:3] meas from the beginning (index 0) to index 3 (the forth item).
4. index: search for an item
list_name.index("name"): search for "name", it equals to index.
5. insert: insert an item
list_name.insert( num, "item") insert "item" at index num, which moves everything down by num.
6. order: sort list_name into alphabetical order
list_name.sort()
7. remove
list_name.remove("item")