Answer to Question #175417 in Python for ola

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()


1
Expert's answer
2021-03-25T03:03:36-0400

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS