Basic Types (Lists)

Lists of arbitrary objects

     a = [2, 3, 4]                   # A list of integers
     b = [2, 7, 3.5, "Hello"]        # A mixed list
     c = []                          # An empty list
     d = [2, [a,b]]                  # A list containing a list
     e = a + b                       # Join two lists 

List manipulation

     x = a[1]                        # Get 2nd element (0 is first)
     y = b[1:3]                      # Return a sublist
     z = d[1][0][2]                  # Nested lists 
     b[0] = 42                       # Change an element 

List methods

     a.append("foo")                 # Append an element
     a.insert(1,"bar")               # Insert an element
     len(a)                          # Length of the list
     del a[2]                        # Delete an element
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 14
July 17, 2000, beazley@cs.uchicago.edu
>>>