Helpful Information
 
 
Category: Python
dictionary values with unlimited data?

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

to add to a dictionary:


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










privacy (GDPR)