While using this in Python 2.7 and changing the inputs to raw_input I received the following output:
C:\Python27\Doc\Python Programs\Book>test.py
Please enter the name of the contact: test1
Please enter the phone number of the contact: 123456789
Please enter the email of the conact: [email protected]
Would you like to add another Contact? (yes or no): yes
Please enter the name of the contact: test2
Please enter the phone number of the contact: 234567891
Please enter the email of the conact: [email protected]
Would you like to add another Contact? (yes or no): no
{'test1': (123456789, '[email protected]'), 'test2': (234567891, '[email protected]')}
Using your exact code.
Your code is running fine. However if you are entering multiple values let's say a same name, number, or email. You are going to change the value. For example from my output, if I put in test1 as the name with the number 123456789 then entered another test1 with the number 987654321 it will replace the first one with the second one. You need to have a set of code to check for multiple inputs that are the same and then inputs them as a new contact rather than replacing the previous one.
I would try something along the lines of adding a function that scans to see if the input already exists in the dictionary contacts. If it does then add it to the dictionary in a different place.
if addContact == 'no'
block.