Your task is to create a phonebook using a dictionary. The keys are the names of the contacts and the values are named tuples containing the following attributes: "phone", "email", and "address". To achieve this create a function add_contact that receives the phonebook dictionary and returns the updated dictionary with a new contact. Before returning the updated dictionary you should print a summary message letting the user know the contact was added successfully and the number of contacts in the phonebook. Here's a sample input:

Respuesta :

Answer:

Please check below for the code. I wrote this task using Python programming language.

Explanation:

phonebook = {}

def add_contact(name,details):

   phonebook[name] = details

   print ('Contact ' + name + ' with phone ' + details[0]

          + ', email ' + details[1] + ' and address ' + details[2]

          + ' has been added successfully!')

   print ('You now have ' + str(len(phonebook)) + ' contact(s) in your phonebook')

   return phonebook

add_contact('Arturo Vidal', ('08140590', 'artvid@barca.com', 'Barcelona'))