CS 110 Lecture Notes - Lecture 11: Mutator Method
Document Summary
Other languages call this an array, but python calls it a list. This creates an empty list. mylist2 = [ chocolate , vanilla , strawberry ] mylist3 = [10,20,30, chocolate , vanilla ] Concatenates the two lists and prints them. Literal: a value that is not stored in a variable. In the above example, [1,2] and [3,4] are literals, because they are used without being stored in a variable. It is possible to have a list of lists (of lists of lists ) del(mylist3) completely deletes the list. You should avoid changing a list while looping through it, to avoid index issues. Aliasing: giving a new name to the same object list1 = [1,2,3] list2 = list1 list2 is just an alias that refers to the same object. If you change the list in list1, it will change list2 as well, because they refer to the same list object.