python quick reference common list methods append(eadds the object to the end of count(ereturns the number of times that occurs in insert(ieinserts the object into at index extend( appends the items in list to the end of remove(edeletes the first occurrence of from index(ereturns the index of the first occurrence of in pop(iremoves and returns the item at index defaults to - sort(has the side effect of sorting the elements of reverse(has the side effect of reversing the order of the elements in common operations on dictionaries len(dreturns the number of items in keys(returns list containing the keys in values(returns list containing the values in in returns true if key is in [kreturns the item in with key raises keyerror if is not in get(kvreturns [kif in dand otherwise [kv associates the value with the key if there is already value associated with kthat value is replaced del [kremoves element with key from raises keyerror if is not in for in iterates over the keys in comparison of common non-scalar types type type of index type of element examples of literals mutable str int characters ''' ''abcno tuple int any type ()( ,)('abc' no list int any type [][ ]['abc' yes dict hashable objects any type {}{' ': }{' ': ' ': yes common input/output mechanisms raw_input(msgprints msg and then returns value entered as string print sn prints strings sn with space between each open('filename'' 'creates file for writing open('filename'' 'opens an existing file for reading open('filename'' 'opens an existing file for appending filehandle read(returns string containing contents of the file filehandle readline(returns the next line in the file filehandle readlines(returns list containing lines of the file filehandle write(swrite the string to the end of the file filehandle writelines(lwrites each element of to the file filehandle close(closes the file