Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A simple address book using lists and the traditional raw_input to accept values
- # created by Egbie Anderson on sunday 13 April 20:00 hrs
- # created using python 2.7x
- # The program uses the append and the pop method as well as raw_string
- # to delete, add and ask a user for raw_input
- # The program asks the user for their name and how many names they would
- # like to add to the address book. The program then adds the name to the address
- # book or it can delete the names too
- address_book = []
- # ask the user for their name
- name = raw_input("[*] what is your name : ")
- surname = raw_input("[*] what is your surname : ")
- print "[*] Creating an empty address book for ", name, surname
- print
- # ask the user for the number of names they will like to add to the address book
- num = int(raw_input("[*] How many names would like to add to your address book. e.g. 2, 3: "))
- print
- # add the names to the address book
- for i in range(num):
- name = raw_input("Enter a name for the address book {no spaces} or 'ENTER' to add nothing: ")
- print "[*] adding ", name, "to the address book."
- address_book.append(name)
- print
- print
- print "[+] Done added ", num, "names to the address book"
- print
- print
- # uncomment the print lines below to display the names in the address book
- print "[*] There are ", num, "names in your address book"
- print "[*] Displaying current address book, please wait.."
- print
- for name in address_book:
- print "Current name within my address book is :", name
- print
- # Deletes names from the address book
- number = int(raw_input("[*] How many names would you like to delete from the address book. e.g. 2, 3: "))
- print
- # delete names from the address book
- for i in range(number):
- name = address_book.pop(0)
- print "Print deleting the name", name, "from the address book: "
- print
- print "[*] Deleted a total of ", number, "names out of ", num, "names"
- # display the state of the current address book after it has been deleted
- print
- print "[*] Displaying current address book, please wait.."
- print
- for name in address_book:
- print "Current name within my address book is now :", name
- print
- raw_input("[*] Press enter to exists program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement