#Create a nested list, and copy it. test = [[5,4],[5.3],[6.7,7]] copy_test= test[:] test.append(['a']) test copy_test #See that they're different lists. #Go through board memory model. #But copy_test[0][0] = False copy_test test #Other things we missed: +,* test = [1,2,3,4] test2=[5,6,7,8] test + test2 test = test*5 test test = [[1,2,3,4]] test*5 #Mention booleans. test test[0][0]=12 test #Danger! Danger! 5 in test2 10 in test2 test2.index(10) #Why in is safer. test2.pop() test2 #back to slides. {'1' : 1, 1 : '1', 'l': []} # a bit perverse test = the above. type(test) test[1] test[3] test[3]=something test[3] test[None] test[['a']]=99 test[3]= something else test[3]#lost original something. Because keys must be unique. #Back to notes. dir(dict) What ones will we look at? len(test) test2={1:1,2:2,3:3} test+test2 test*5 test.keys() test.values() test.items() #Note tuples! Mention itervariants in slides. test[something not in test] something not in test in test test.has_key(something not in test) test.get(something in test) test.get(something not in test) test.get(something not in test, d) #This can be nice for default behaviours. #can save on if statements. Say you're counting volcano eruptions to sum them, if there are none in a year you didn't add the year. So you can return 0, rather than have a complicated if statement. Maybe write code to this effect. test2 test2.clear() test2 test #make sure there is a mutable element. test2= test.copy test[new thing] = new tthing test test2 #different dictionaries test2[mutable element] = something different. test test2 #same problem as with nested lists. test3 = new dictionary with unique elements. test.update(test3_ test test3 test.pop(key) test test.pop(key again) # To slides. dir(dict) # These e