Key takeaways 1. The list is a type of data in Python used to store multiple objects. It is an ordered and mutable collection of comma-separated items between square brackets, e.g.: my_list = [1, None, True, "I am a string", 256, 0] 2. Lists can be indexed and updated, e.g.: my_list = [1, None, True, 'I am a string', 256, 0] print(my_list[3]) # outputs: I am a string print(my_list[-1]) # outputs: 0 my_list[1] = '?' print(my_list) # outputs: [1, '?', True, 'I am a string', 256, 0] my_list.insert(0, "first") my_list.append("last") print(my_list) # outputs: ['first', 1, '?', True, 'I am a string', 256, 0, 'last'] 3. Lists can be nested, e.g.: my_list = [1, 'a', ["list", 64, [0, 1], False]] You will learn more about nesting in module 3.1.7 - for the time being, we just want you to be aware that something like this is possible, too. 4. List elements and lists can be deleted, e.g.: my_list = [1, 2, 3, 4] del my_list[2] print(my_list) # outputs: [1, 2, 4] del my_list # deletes the whole list Again, you will learn more about this in module 3.1.6 - don't worry. For the time being just try to experiment with the above code and check how changing it affects the output. 5. Lists can be iterated through using the for loop, e.g.: my_list = ["white", "purple", "blue", "yellow", "green"] for color in my_list: print(color) 6. The len() function may be used to check the list's length, e.g.: my_list = ["white", "purple", "blue", "yellow", "green"] print(len(my_list)) # outputs 5 del my_list[2] print(len(my_list)) # outputs 4 7. A typical function invocation looks as follows: result = function(arg), while a typical method invocation looks like this:result = data.method(arg). Key takeaways 1. You can use the sort() method to sort elements of a list, e.g.: lst = [5, 3, 1, 2, 4] print(lst) lst.sort() print(lst) # outputs: [1, 2, 3, 4, 5] 2. There is also a list method called reverse(), which you can use to reverse the list, e.g.: lst = [5, 3, 1, 2, 4] print(lst) lst.reverse() print(lst) # outputs: [4, 2, 1, 3, 5] Key takeaways 1. If you have a list l1, then the following assignment: l2 = l1 does not make a copy of the l1 list, but makes the variables l1 and l2 point to one and the same list in memory. For example: vehicles_one = ['car', 'bicycle', 'motor'] print(vehicles_one) # outputs: ['car', 'bicycle', 'motor'] vehicles_two = vehicles_one del vehicles_one[0] # deletes 'car' print(vehicles_two) # outputs: ['bicycle', 'motor'] 2. If you want to copy a list or part of the list, you can do it by performing slicing: colors = ['red', 'green', 'orange'] copy_whole_colors = colors[:] # copy the entire list copy_part_colors = colors[0:2] # copy part of the list 3. You can use negative indices to perform slices, too. For example: sample_list = ["A", "B", "C", "D", "E"] new_list = sample_list[2:-1] print(new_list) # outputs: ['C', 'D'] 4. The start and end parameters are optional when performing a slice: list[start:end], e.g.: my_list = [1, 2, 3, 4, 5] slice_one = my_list[2: ] slice_two = my_list[ :2] slice_three = my_list[-2: ] print(slice_one) # outputs: [3, 4, 5] print(slice_two) # outputs: [1, 2] print(slice_three) # outputs: [4, 5] 5. You can delete slices using the del instruction: my_list = [1, 2, 3, 4, 5] del my_list[0:2] print(my_list) # outputs: [3, 4, 5] del my_list[:] print(my_list) # deletes the list content, outputs: [] 6. You can test if some items exist in a list or not using the keywords in and not in, e.g.: my_list = ["A", "B", 1, 2] print("A" in my_list) # outputs: True print("C" not in my_list) # outputs: True print(2 not in my_list) # outputs: False