Code: Select all
dictionary={"Hello" : "A word", "Hi" : "Another word", "Yo!" : "Yet another word"}
print("Welcome to the dictionary.\n")
print("To begin, type your option.")
print("a) Search for a word")
print("b) Enter a word")
print("c) Display all words")
answer = raw_input()
if answer == "a" or "a)" or "A" or "A)" :
word = raw_input("What word would you like to search for? ")
if word in dictionary :
print(dictionary[word])
else :
print("Word not found!")
elif answer == "b" or "b)" or "B" or "B)" :
word = raw_input("Enter a word: ")
definition = raw_input("Enter the definition: ")
dictionary[word] = definition
elif answer == "c" or "c)" or "C" or "C)" :
for k, v in dictionary.iteritems() :
print (k+" - "+v)