fh close(this produces the following resultwritten content in the file successfully exception with arguments why use argument in exceptionsusing arguments for exceptions in python is useful for the following reasonsit can be used to gain additional information about the error encountered as contents of an argument can vary depending upon different types of exceptions in pythonvariables can be supplied to the exceptions to capture the essence of the encountered errors same error can occur of different causesarguments helps us identify the specific cause for an error using the except clause it can also be used to trap multiple exceptionsby using variable to follow the tuple of exceptions arguments in buil-in exceptionsthe below codes demonstrates use of argument with built-in exceptionsexample tryb float( except exception as argumentprint'this is the argument\ 'argumentoutputthis is the argument division by zero arguments in user-defined exceptionsthe below codes demonstrates use of argument with user-defined exceptions