Basic Types (Lists)Lists of Arbitrary Objectsa = [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 Manipulationx = 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 |
<<< | O'Reilly OSCON 2000, Advanced Python Programming, Slide 11 July 17, 2000, beazley@cs.uchicago.edu |
>>> |