...

dictionary values with unlimited data?

velious
07-10-2007, 05:04 AM
I'm trying to make a simple phone book program. I'm using one dictionary value called 'contact' to hold all the names and numbers that are entered.

How do i make this variable grow as the user imputs data without erasing the old?

---

def add_contact():
name_list = raw_input('add a name to contacts \n')
num_list = raw_input('add a number\n')

contact = {name_list: num_list}
print name_list,'(', num_list, ') has been added'


def edit_file(phone_book):
print ''


def menue():
print ' What would you like to do? '
print '1. Edit phone book\n2. Add names'
x = raw_input()
if int(x) == 1:
edit_file(phone_book)
else:
add_contact()
menue()


---

thanks

ghostdog74
07-12-2007, 04:00 PM
to add to a dictionary:

....
contact[name] = num
...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum