← Back to Files
Question 437
JSON Contact Book
JSON Contact Book
Input: the first line is a whole number n, then n lines each holding a name and a phone number separated by one space (for example Maya 555-0101), then one final line with the name to look up; no prompts. Read the n entries with a for over range(n), splitting each line with split(), into a dict that maps each name to its phone number; save it to contacts.json with json.dump and indent=2, then load the file back with json.load into a second variable and answer from that copy only: print <n> contact(s) saved with the length of the loaded dict, then either <name>: <phone> or No entry for <name> (test with in). Import only json.
Expected Output:
2 contact(s) saved Omar: 555-0199
= newline. The output ends with a newline — print one after the last line.
Hints4 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.