← Back to Files
Question 418
Decode A JSON Line
Decode A JSON Line
The JSON object read from input (one line with the keys title and pages) is written to book.json. Open the file for reading, read the text back with f.read() into text, decode it with json.loads into book and print <title> has <pages> pages from that dict. Input: one line of JSON, no prompt. Import only json.
Expected Output:
Dune has 412 pages= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
FilesJSON
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.