DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Error Handling — Example 116

Quick explanation + ready code for: Error Handling.

Python Error Handling Back to examples
Back to language
Syntax: Error Handling in Python. ID: #116

Code

import json
try:
  json.loads("{bad}")
except Exception as e:
  print("error:", e)

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.