0
#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

Edited by SnHnBoLt: spelling mistakes

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by pyTony
1

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

Edited by pyTony

Comments
Thank you very much.It works fine after lowering the case of keys. :-)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.