Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!