# Open new file to write file = None try: file = open(filePath, \'w\') except IOError: msg = (\"Unable to create file on disk.\") file.close() return
what is the logic in including the
file.write("Hello World!")
inside the finally clause?? i think it must be put in try clause itself.
finally
try
try: file = open(filePath, 'w') file.write("Hello World!") except IOError: print("Unable to create file on disk.") finally: file.close()