Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. >>> >>> string = "Smith College" >>> tokens = string.split() >>> string 'Smith College' >>> tokens ['Smith', 'College'] >>> # indexing: strings, lists, dictionaries [..] >>> string[1] 'm' >>> tokens[1] 'College' >>> tokens[1:] ['College'] >>> type(tokens[1:]) >>> type(tokens[1]) >>> # whenever you see [..:..], that's slicing >>> # slicing: strings, lists (not dict because no order) >>> >>> >>> lst = ["A","B","C"] >>> lst[3] = "D" Traceback (most recent call last): File "", line 1, in lst[3] = "D" IndexError: list assignment index out of range >>> dictionary = {0: "A", 1: "B", 2: "C"} >>> dictionary[3] = "D" >>> dictionary {0: 'A', 1: 'B', 2: 'C', 3: 'D'} >>> dictionary[0] = "AA" >>> dictionary {0: 'AA', 1: 'B', 2: 'C', 3: 'D'} >>> dictionary[0] = "A" >>> dictionary[26] = "a" >>> dictionary[27] = "b" >>> dictionary {0: 'A', 1: 'B', 2: 'C', 3: 'D', 26: 'a', 27: 'b'} >>> dictionary.keys() dict_keys([0, 1, 2, 3, 26, 27]) >>> type(dictionary) >>> for key in dictionary.keys(): print(key, dictionary[key]) # key, value pair 0 A 1 B 2 C 3 D 26 a 27 b >>> for key in dictionary: print(key, dictionary[key]) # key, value pair 0 A 1 B 2 C 3 D 26 a 27 b >>> string_dict = {} >>> string_dict["hello"] = 5 >>> string_dict["how"] = 3 >>> string_dict["I"] = 1 >>> string_dict {'hello': 5, 'how': 3, 'I': 1} >>> string_dict["a"] = 1 >>> string_dict {'hello': 5, 'how': 3, 'I': 1, 'a': 1} >>> dict_99 = {} >>> dict_99[99355252] = ["CSC","BIO","ART","ARS"] >>> dict_99 {99355252: ['CSC', 'BIO', 'ART', 'ARS']} >>> dict_99[99355252].append("ENG") >>> dict_99[99355252].append("EGR") >>> >>> dict_99 {99355252: ['CSC', 'BIO', 'ART', 'ARS', 'ENG', 'EGR']} >>>