Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. action1 = input("Hello there. Welcome to the address book app. Would you like to add a contact or search for a contact?")
  2. print ('')
  3.  
  4. addressbook1= {
  5. "Name: ": "Alexander Achcar",
  6. "Phone number: ": " 32031288",
  7. "Email address: ": "alex.achcar@gmail.com",
  8. }
  9.  
  10. addressbook2= {
  11. "Name: ": "Ivanka Trump",
  12. "Phone number: ": "18003728933",
  13. "Email address: ": "FDOTUS@gmail.com",
  14.  
  15. }
  16.  
  17. addressbook3= {
  18. "Name: ": "Tiger Woods",
  19. "Phone number: ": "145621413222",
  20. "Email address: ": "golflegend@gmail.com",
  21. }
  22.  
  23. while [True]:
  24.  
  25. if action1.lower() == "add":
  26. action2 = input("Please enter the contact's name:")
  27. if action2.isalpha():
  28. print ('')
  29. action3 = input("What is " + action2 + "'s" " phone number?")
  30. print ('')
  31. if action3.isdigit():
  32. print ('')
  33. action4 = input("What is " + action2 + "'s" " email address?")
  34. print ('')
  35. if "@" and ".com" in action4:
  36. print ("Here are the details:")
  37. print ('')
  38. print("Name: " + action2)
  39. print("Phone number: " + action3)
  40. print("Email address: " + action4)
  41. break
  42. elif "@" and ".org" in action4:
  43. print ("Here are the details:")
  44. print ('')
  45. print("Name: " + action2)
  46. print("Phone number: " + action3)
  47. print("Email address: " + action4)
  48. break
  49. else:
  50. print ('')
  51. print("Please type a valid email address.")
  52. print ('')
  53. elif action3.isalpha():
  54. print ('')
  55. print("Please type a valid phone number.")
  56. print ('')
  57. else:
  58. print ('')
  59. print ('Wrong input.')
  60. elif action2.isdigit():
  61. print ('')
  62. print ("Please type a valid name.")
  63. else:
  64. print ('')
  65. print ('Wrong input.')
  66.  
  67. elif action1.lower() == "search":
  68. letter_alphabet = input("Type a single letter of the alphabet to find a contact.")
  69.  
  70. if letter_alphabet.upper() == "A":
  71. for key, value in sorted(addressbook1.items()):
  72. print (key + value)
  73.  
  74. elif letter_alphabet.upper() == "I":
  75. for key, value in sorted(addressbook2.items()):
  76. print (key + value)
  77.  
  78. elif letter_alphabet.upper() == "T":
  79. for key, value in sorted(addressbook3.items()):
  80. print (key + value)
  81.  
  82. else:
  83. print ('')
  84. print ('Wrong input.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement