python04(): Exercises for lists. Create a list of colleges ['Carlow', 'Chatham', 'CMU', 'Duquesne', 'University of Pittsburgh'] Chatham ['Chatham', 'CMU', 'Duquesne'] University of Pittsburgh Number of colleges in list is 5 Replace, modify, append, remove entries. ['Carlow', 'Chatham', 'CMU', 'Robert Morris', 'University of Pittsburgh'] ['Carlow', 'Chatham', 'CMU', 'Robert Morris University', 'University of Pittsburgh'] ['Carlow', 'Chatham', 'CMU', 'Robert Morris University', 'University of Pittsburgh', 'Point Park'] ['Carlow', 'CMU', 'Robert Morris University', 'University of Pittsburgh', 'Point Park'] Remove an entry by index. ['Carlow', 'CMU', 'Robert Morris University', 'University of Pittsburgh', 'Point Park'] value = colleges.pop(1) = CMU ['Carlow', 'Robert Morris University', 'University of Pittsburgh', 'Point Park'] value = colleges.pop(1) = Robert Morris University ['Carlow', 'University of Pittsburgh', 'Point Park'] value = colleges.pop(0) = Carlow ['University of Pittsburgh', 'Point Park'] The len() function reports the length of a list: len(colleges) = 2 len ( [ 10, 20, 30, 40 ] ) = 4 A list can contain a mixture of types: patient0 = ['Robert Baratheon', 235.4, 73, False] patient1 = ['Arya Stark', 134.7, 68, True] The + sign will concatenate lists. odd = [1, 3, 5, 7, 9] prime = [2, 3, 5, 7] oddplusprime = [1, 3, 5, 7, 9, 2, 3, 5, 7] oddandprime = [2, 3, 5, 7] A list can contain lists: patientpluspatient = ['Robert Baratheon', 235.4, 73, False, 'Arya Stark', 134.7, 68, True] patients= [['Robert Baratheon', 235.4, 73, False], ['Arya Stark', 134.7, 68, True]] patients[1]= ['Arya Stark', 134.7, 68, True] patients[0][1]= 235.4 Use append to add one more list to a list of lists: [['Robert Baratheon', 235.4, 73, False], ['Arya Stark', 134.7, 68, True], ['Tyrion Lannister', 140.5, 50, True]] A list name is only a pointer. A=B makes a new pointer, but not a new set of values. prime = [3, 5, 7] odds = [3, 5, 7] A=B.copy() makes a new pointer and a new set of values. prime = [3, 5, 7] odds = [1, 3, 5, 7, 9]