(the parentheses are required)def attempt_float( )tryreturn float(xexcept (typeerrorvalueerror)return in some casesyou may not want to suppress an exceptionbut you want some code to be executed regardless of whether the code in the try block succeeds or not to do thisuse finallyf open(path' 'trywrite_to_file(ffinallyf close(herethe file handle will always get closed similarlyyou can have code that executes only if the tryblock succeeds using elsef open(path' 'trywrite_to_file(fexceptprint 'failedelseprint 'succeededfinallyf close(range and xrange the range function produces list of evenly-spaced integersin [ ]range( out[ ][ both startendand step can be givenin [ ]range( out[ ][ as you can seerange produces integers up to but not including the endpoint common use of range is for iterating through sequences by indexseq [ for in range(len(seq))val seq[ifor very long rangesit' recommended to use xrangewhich takes the same arguments as range but returns an iterator that generates integers one by one rather than generating appendixpython language essentials www it-ebooks info