Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Exercise 1: Nested Dictionaries Create a new function called AddNewFullContact Add a parameter that will be a dictionary that we will store a collection
Python:
Exercise 1: Nested Dictionaries
- Create a new function called AddNewFullContact
- Add a parameter that will be a dictionary that we will store a collection of contacts with their associated contact info
- Ask the user for the following information:
- name - "Please enter the name of your friend: "
- number - "What is your friend's 7-digit phone number? ", "That's not 7 digits, try again: "
- email - "What is your friend's email address? "
- age (between 0 and 125, inclusive) - "What is your friend's age? ", "That's not a real age, try again: "
- Store the "number", "email", and "age" (be sure to use exactly those words) into a new dictionary (not the function's parameter!) that will represent name's contact info
- Store the entire dictionary into the contacts dictionary using name as its key
- Using a loop, add 5 contacts to the dictionary using AddNewFullContact
- Pretty print the dictionary
- Print all of the names in the dictionary (hint: keys)
- Print all of the full contact info in the dictionary (hint: values)
- Ask the user for the name they want to look up, "Whose number do you want? "
- Pretty print this contact's full contact info
- Print out just the email associated with that name
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started