⚑ IT Wisdom My Docker containers are running perfectly. The application inside them is a different conversation.
Skilled Practitioner
4249 XP 1751 to Expert
Objective: Use try/except to catch a FileNotFoundError and print a helpful message.
Instructions

Create a file called lab1.py. Write a script that tries to open a file called missing_devices.txt. Since this file does not exist, the open will fail β€” catch the exception and print a helpful error message instead of crashing.

Your output must match exactly:

Error: device list file not found
Please provide a valid file path

Run it with python3 lab1.py. Paste your output below and submit.

Starter Code
try:
    with open("missing_devices.txt") as f:
        content = f.read()
        print(content)
except FileNotFoundError:
    print("Error: device list file not found")
    print("Please provide a valid file path")
πŸ’‘ Show Hint
The file missing_devices.txt does not exist β€” that is the point. Python raises FileNotFoundError when open() cannot find the file. Catch it in the except block.
Paste Your Output
Next Lab β†’