Create Pretty JSON
Intermediate · Write the code · 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 lessonCreate a Python dictionary with keys 'name' (value 'Alice'), 'age' (value 25), and 'hobbies' (value ['reading', 'hiking']). Convert it to a pretty-printed JSON string with 2-space indentation and print it.
import json
# Your code here
More JSON exercises
- Parse a JSON StringBeginner
- Predict the JSON OutputBeginner
- Fix the JSON Parsing BugIntermediate
- Refactor String Concatenation to json.dumpsIntermediate
- Extract Data from Nested API JSONAdvanced
All Python exercises · 50 practice problems · File I/O & Data Formats quiz