Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    California
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post
    to add to a dictionary:
    Code:
    ....
    contact[name] = num
    ...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •