livepython.net

111. Fix the Broken Phone Book Dictionary

MediumDictionary

Overview

This phone book has two mistakes that stop Python, and one that doesn't. Find all three.

Problem Statement

The starter code should store three contacts: Sunny's number is 98765, Rocky's is 91234 and Lucky's is 99887. Then it prints the dictionary and the number of contacts. Fix the code so it prints exactly:

{'Sunny': '98765', 'Rocky': '91234', 'Lucky': '99887'}
Contacts: 3

Fix the errors one at a time: run, read the error, fix that line, and run again. When it runs, check that the output really matches.

Input

No input is required for this question.

Output

{'Sunny': '98765', 'Rocky': '91234', 'Lucky': '99887'}
Contacts: 3

Learn this firstChapter 13 · Python Dictionary: Store Data in Key-Value Pairs
solution.py
phone_book = {"Sunny" = "98765", "Rocky": "91234" "Sunny": "99887"}
print(phone_book)
print("Contacts:", len(phone_book))

EXPECTED OUTPUT

1{'Sunny': '98765', 'Rocky': '91234', 'Lucky': '99887'}
2Contacts: 3

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.