Created
April 30, 2025 01:28
-
-
Save vblackburn0305/39d4946b71ed94c1f1bfe57fd8704fd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Part 1: | |
<def throw_me_an_error(): | |
try: | |
val1 = 14 | |
val2 = 0 | |
return val1 / val2 | |
except ZeroDivisionError as e: | |
print(f"Error occurred: {e}") | |
throw_me_an_error()> | |
Part 2: | |
<# The finally block ensures that the file is closed even if an exception occurs during the write process. This helps avoid leaving files open.> | |
Part 3: | |
<import json | |
data = '{"invalid_json_key": "value"}' | |
try: | |
parsed_data = json.loads(data) | |
print(parsed_data) | |
except json.JSONDecodeError as e: | |
print(f"JSON import error: {e}")> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment