#Dictionary practice

def menu():
    print("1. Add name and number")
    print("2. Print the directory")
    print("3. Quit")

options = 0
directory = {}

while options < 3 :
    menu()
    options = int(input("Enter your desired option :"))
    if options == 1 :
        print("You selected to add name and number")
        name = input("Enter name :")
        number = input("Enter number :")
        directory[name] = number
    elif options == 2 :
        print("Directory")
        for x in directory.Keys() :
            print("Name :",x,"\tDirectory:",directory[x])
    else :
        if options == 3 :
            print("Quiting .......")

This is a program I created but I am having trouble printing my directory please anyone help me with this

Re: I am new to python.Please Help me with the dictionaries in python 80 80

Take out .Keys()(it is .keys() but it is default for iteration)
Variable name number is not logical for string.

commented: Thank you very much.It works fine after lowering the case of keys. :-) +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.