Solution: #The try block of code will raise an error when trying to open non-existed python text file: try:   f = open("python.txt") except:   print("Something went wrong when try to open the file") finally:   f.close() #The code continue, without leaving the file opened if the file is exist: #if the file is not exist we get: ->> Something went wrong when try to open the file