Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Dictionaries

def menu(): print("""1-Add a new name and email address 2-Change an existing email address 3-Delete an existing name and email address 4-Look up a person's email address 5-Exit""") def main(): menu() choice=int(input("Please enter your choice from the menu: ")) name_dict={} while choice!=5: name_dict={} if choice==1: name=input("Please input name: ") email=input("Please input email address: ") if name in name_dict: print("This name already exists!") else: name_dict[name]=[email] print(name_dict)

elif choice==2:
    name=input("please input the name you want to edit: ")
    if name in name_dict:
        email=input("please enter the new email: ")
        name_dict[name]=[email]
        print(name_dict)
    else:
        print("This name doesn't exist")


elif choice==3:
    name=input("Please enter the name you would like to delete: ")
    if name in name_dict:
        del name_dict[name]
        print(name_dict)
    else:
        print("This name doesn't exist")


elif choice==4:
    name=input("Please enter the name you would like to search for: ")
    if name in name_dict:
        name_dict.get(name)
    else:
        print("This name doesn't exist")

else: exit() main()

i am having a problem with my code and I'm not being able to figure it out. my dictionary isn't saving what I'm writing. I only want to make a list of names with emails as key-value pairs. Can anyone help please?