Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- action1 = input("Hello there. Welcome to the address book app. Would you like to add a contact or search for a contact?")
- print ('')
- addressbook1= {
- "Name: ": "Alexander Achcar",
- "Phone number: ": " 32031288",
- "Email address: ": "alex.achcar@gmail.com",
- }
- addressbook2= {
- "Name: ": "Ivanka Trump",
- "Phone number: ": "18003728933",
- "Email address: ": "FDOTUS@gmail.com",
- }
- addressbook3= {
- "Name: ": "Tiger Woods",
- "Phone number: ": "145621413222",
- "Email address: ": "golflegend@gmail.com",
- }
- while [True]:
- if action1.lower() == "add":
- action2 = input("Please enter the contact's name:")
- if action2.isalpha():
- print ('')
- action3 = input("What is " + action2 + "'s" " phone number?")
- print ('')
- if action3.isdigit():
- print ('')
- action4 = input("What is " + action2 + "'s" " email address?")
- print ('')
- if "@" and ".com" in action4:
- print ("Here are the details:")
- print ('')
- print("Name: " + action2)
- print("Phone number: " + action3)
- print("Email address: " + action4)
- break
- elif "@" and ".org" in action4:
- print ("Here are the details:")
- print ('')
- print("Name: " + action2)
- print("Phone number: " + action3)
- print("Email address: " + action4)
- break
- else:
- print ('')
- print("Please type a valid email address.")
- print ('')
- elif action3.isalpha():
- print ('')
- print("Please type a valid phone number.")
- print ('')
- else:
- print ('')
- print ('Wrong input.')
- elif action2.isdigit():
- print ('')
- print ("Please type a valid name.")
- else:
- print ('')
- print ('Wrong input.')
- elif action1.lower() == "search":
- letter_alphabet = input("Type a single letter of the alphabet to find a contact.")
- if letter_alphabet.upper() == "A":
- for key, value in sorted(addressbook1.items()):
- print (key + value)
- elif letter_alphabet.upper() == "I":
- for key, value in sorted(addressbook2.items()):
- print (key + value)
- elif letter_alphabet.upper() == "T":
- for key, value in sorted(addressbook3.items()):
- print (key + value)
- else:
- print ('')
- print ('Wrong input.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement