Read a Contact
Python
15 pts
Read a Contact
A contact is stored in a dictionary:
contact = {"name": "Merhawi", "city": "Massawa", "phone": "07-123456"}
- Create
namewith the value of the"name"key (use square brackets). - Create
emailwithget(). The key"email"does not exist, so use the default"not saved". - Create
has_phonethat isTrueif the key"phone"is incontact(usein). - Print the three variables, one per line.
Expected output:
Merhawi not saved True
Checklist
- Leave
contactas it is and read the name intonamewith square brackets. - Create
emailso that it gets"not saved"when the key is missing. - Create
has_phonethat tells you whether the key"phone"exists. - Print the three variables, one per line.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
