Source: https://docs.google.com/presentation/d/1B1uvAncCjrUJit6HcesvqkggYXr7nSk02cNN_FvAWtQ/edit#slide=id.g2b048740d87_0_71

Iterable

An iterable object is

  • anything that can be looped over or
  • anything that can appear on the right side of a for loop

Lists

lst = []  
lst = list()  
lst = list("string")  

List Manipulations

  • Negative indexing: lst[-2]
  • List slicing: test[1:3]
  • Shrinking lists: test[1:3] = 17

Mutability/Immutability

Difference between plus and append

”+” returns a copy
Append mutates

Tuples

Iterable data structure
Very similar to lists:

  • indexing, can store different types of data, slicing
    Immutable
    Tuples with a single item: ("carter",)

Dictionaries

Allows you to associate values with keys
Dictionaries are now ordered collections of key-value pairs (as of 3.7, guaranteed to be in insertion order)
Key: unique identifier (where we can find our data) (can only be immutable)
Value: the data to find.