Lists Quick Review

Lists = An ordered sequence of values where indexing starts at 0 (not 1!)

List slicing = Creating a copy of a portion or all of a list

List comprehension = A compact, one line for loop that returns a list

Important List Functions

range(a, b): Gives a list of numbers from a to b excluding b

len(lst): Gives the length of lst

lst.append(x): Adds element x onto the end of a lst and returns none -- if x is a list, the last element of lst becomes a pointer to list x

lst.extend(x): Adds a list onto the end of a list and returns none (in this case, x has to be a list, not just one element)

lst.pop(x): Removes and returns element at index x (or the last element if no index is specified)

lst.remove(x): Removes element x from lst (or does nothing if x is not in lst) and returns none