Project 22: Video Player Layout
Python Challenge
Builds on these lessons
Step 1 of 3
Project
Recovering from a Failed Load
Wrap a simulated video load in try/except, falling back to a lower-quality stream URL on failure instead of stopping playback entirely. Error recovery means the program keeps going in a degraded-but-working state — not every failure needs to be fatal.
🎯 Your Task
Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!
def load_video(quality):
if quality == "4k":
raise ConnectionError("4k stream unavailable")
return f"Playing at {quality}"
try:
result = load_video("4k")
except ConnectionError:
result = load_video("720p")
print(result)