Devise a Python program to create a dictionary for words and their meanings
def
insertword(worddic,word,meaning):
worddic[word]=meaning
print("Inserted")
def
searchmeaning(worddic,word):
if word in worddic.keys():
print("The meaning
of",word,"is",worddic[word])
else:
print("word you search does not
exist")
worddic={}
while
True:
print("1.Insert new word")
print("2.search meaning")
choice=int(input("enter menu
option:"))
if choice==1:
word=input("enter word to
insert:").lower()
meaning=input("enter the meaning
of the word:").lower()
insertword(worddic,word,meaning)
print("dictionary:",worddic)
elif choice==2:
if len(worddic)>0:
word=input("enter word to get
the meaning:").lower()
searchmeaning(worddic,word)
else:
print("Dictionary is
empty")
OUTPUT
1.Insert new word
2.search meaning
enter menu option:1
enter word to insert:Ferocious
enter the meaning of the word:Aggressive
Inserted
dictionary: {'ferocious': 'aggressive'}
1.Insert new word
2.search meaning
enter menu option:1
enter word to insert:Serendipity
enter the meaning of the word:The occurrence of
pleasant or fortunate events by chance.
Inserted
dictionary: {'ferocious': 'aggressive',
'serendipity': 'the occurrence of pleasant or fortunate events by chance.'}
1.Insert new word
2.search meaning
enter menu option:1
enter word to insert:Oblivion
enter the meaning of the word:The state of being
unaware or unconscious of what is happening.
Inserted
dictionary: {'ferocious': 'aggressive',
'serendipity': 'the occurrence of pleasant or fortunate events by chance.',
'oblivion': 'the state of being unaware or unconscious of what is happening.'}
1.Insert new word
2.search meaning
enter menu option:2
enter word to get the meaning:OBLIVION
The meaning of oblivion is the state of being
unaware or unconscious of what is happening.
1.Insert new word
2.search meaning
enter menu option: