Editor

Fix the JSON Parsing Bug

Intermediate · Fix the bug · from Python JSON: Parse, Create, and Manipulate JSON Data

From the lesson: Python JSON: Parse, Create, and Manipulate JSON Data

Imagine a universal language that every app, website, and database can understand. That's JSON (JavaScript Object Notation). It's the most popular format for sending data between computers.

Read the lesson

This code tries to parse a JSON string and print a nested value, but it crashes. Fix the bug so it prints the expected output.

Expected output:

Language: Python
import json
json_str = '{"course": {"name": "Intro to Programming", "language": "Python"}}'
data = json.loads(json_str)
print(f'Language: {data["language"]}')

More JSON exercises

All Python exercises · 50 practice problems · File I/O & Data Formats quiz