#Dictionary practice

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

options = 0
directory = {}

while options < 3 :
    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 :
        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

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.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.