Fill in the blanks to try to open and read from a file. Print an error message in case of an exception. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Fill in the blanks to try to open and read from a file. Print an error message in case of an exception.

Python 5th Module Quiz try : with open("test.txt") as f: print(f.read) ...................... print("Error)

13th Dec 2020, 7:44 PM
Kenny N
Kenny N - avatar
1 Answer
0
q)try to open and read from a file print an error message in case of an exception? ans: try: with open("test.txt") as f: print(f.read()) except: print("error")
26th May 2021, 7:07 AM
Madhavareddy
Madhavareddy - avatar