Advertisement
egbie

address book

Apr 13th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. # A simple address book using lists and the traditional raw_input to accept values
  2. # created by Egbie Anderson on sunday 13 April 20:00 hrs
  3. # created using python 2.7x
  4.  
  5. # The program uses the append and the pop method as well as raw_string
  6. # to delete, add and ask a user for raw_input
  7.  
  8. # The program asks the user for their name and how many names they would
  9. # like to add to the address book. The program then adds the name to the address
  10. # book or it can delete the names too
  11.  
  12. address_book = []
  13.  
  14. # ask the user for their name
  15. name = raw_input("[*] what is your name : ")
  16. surname = raw_input("[*] what is your surname : ")
  17.  
  18. print "[*] Creating an empty address book for ", name, surname
  19. print
  20.  
  21. # ask the user for the number of names they will like to add to the address book
  22. num = int(raw_input("[*] How many names would like to add to your address book. e.g. 2, 3: "))
  23. print
  24.  
  25. # add the names to the address book
  26. for i in range(num):
  27.     name = raw_input("Enter a name for the address book {no spaces} or 'ENTER' to add nothing: ")
  28.     print "[*] adding ", name, "to the address book."
  29.     address_book.append(name)
  30.     print
  31.  
  32. print
  33. print "[+] Done added ", num, "names to the address book"
  34. print
  35. print
  36.  
  37. # uncomment the print lines below to display the names in the address book
  38. print "[*] There are ", num, "names in your address book"
  39. print "[*] Displaying current address book, please wait.."
  40. print
  41.  
  42. for name in address_book:
  43.     print "Current name within my address book is :", name
  44. print
  45.  
  46. # Deletes names from the address book
  47. number = int(raw_input("[*] How many names would you like to delete from the address book. e.g. 2, 3: "))
  48. print
  49.  
  50. # delete names from the address book
  51. for i in range(number):
  52.  
  53.     name = address_book.pop(0)
  54.     print "Print deleting the name", name, "from the address book: "
  55.  
  56. print
  57. print "[*] Deleted a total of ", number, "names out of ", num, "names"
  58.  
  59. # display the state of the current address book after it has been deleted
  60. print
  61. print "[*] Displaying current address book, please wait.."
  62. print
  63.  
  64. for name in address_book:
  65.     print "Current name within my address book is now :", name
  66.  
  67. print
  68. raw_input("[*] Press enter to exists program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement