Question #175417

After the Python code below has run, what happens if 'the_file' does not already exist?

try:

   fin = open('the_file', 'r')

except:

  fin = open('the_file', 'w')

fin.close()


Expert's answer

If the file does not already exists, a new file is created for it as specified by the except block of code


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS