Project 1 - English Dictionary App & Library Book Management System
import json
dic= {}
dic[1]=2
file= open('word.txt','w')
json.dump(dic,file)
file.close()
def add():
file = open('word.txt','w')
word = input("enter a word")
meaning = input("enter a meaning")
dic[word]=meaning
json.dump(dic,file)
file.close
def update():
file= open('word.txt','r')
dic=json.load(file)
file.close()
word = str(input('enter a word :'))
if word in dic:
meaning = str(input('enter the updating word'))
print("meaning of word is",meaning)
else:
print('word not found !')
file=open('word.txt','w')
dic[word]=meaning
json.dump(dic,file)
file.close()
def find():
file=open('word.txt','r')
dic=json.load(file) #load the file
word=input("enter a word")
if word in dic:
print('meaning of the word is :',dic[word])
else:
print("enteredword is not found")
file.close()
while True:
print("Main Menu")
print("1.Add a new word")
print("2.Find the Meaning")
print("3.Update the word")
print("4.exit")
ch = input("enter your choice :")
if ch == '1':
add()
elif ch=='2':
find()
elif ch == '3':
update()
elif ch=='4':
exit()
break
else :
print('invalid choice')