Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import pickle
  2.  
  3. email = {'John':'John_Email@gmail.com', 'Sara':'Sara_Email@gmail.com', 'Harry':'Harry_Email@gmail.com'}
  4.  
  5. file_mail = open('email.dat','wb')
  6.  
  7. email = pickle.load(file_mail)
  8. file_mail.close()
  9.  
  10. print(email)
  11. count = 0
  12.  
  13. while count == 0:
  14. print('Add an email address: 1')
  15. print('Modify an email address: 2')
  16. print('Delete an email address: 3')
  17. print('Display a list: 4')
  18.  
  19. choice = input('Enter a number from the list above:')
  20.  
  21. if int(choice)== 1:
  22. name = input('Enter name:')
  23. mail = input('Enter e-mail address:')
  24. email[name] = mail
  25. print('Added Successfully')
  26.  
  27. if int(choice) == 2:
  28. name = input('Enter name:')
  29. mail = input('Enter e-mail address:')
  30. email[name] = mail
  31. print('Modified Successfully')
  32.  
  33. if int(choice) == 3:
  34. name = input('Enter name:')
  35. mail = input('Enter e-mail address:')
  36. email[name] = mail
  37. print('Deleted Successfully')
  38.  
  39. if int(choice) == 4:
  40. print(email)
  41.  
  42. else:
  43. print('Invalid Choice')
  44. c = input('Do you want to continue y/n: ')
  45.  
  46. if c.upper() == 'N':
  47. count = 1
  48. print('Invalid Letter')
  49. file_mail = open('email.dat','wb')
  50. pickle.dump(email,file_mail)
  51. file_mail.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement