Project 1 - English Dictionary App & Library Book Management System
Project1:
Q 1A. English Dictionary App
import json
choice=1
while(choice!=4):
choice=int(input('''Main Menu
Press 1... to Add new word
Press 2... to Search word
Press 3...to Update the word
Press 4... to Exit
Enter the choice : '''))
print("Your choice is : ",choice)
if (choice==2):
word=input("Enter the word you want to search :").title()
with open('words.txt','r') as f:
a=json.load(f)
for i in a:
if (word==i):
print("Meaning of : ",word,"is :",a[i])
break
else:
print("No word in dictionery you can try adding")
elif(choice==1):
temp={}
temp1={}
word=input("Enter the new word : ").title()
with open("words.txt",'r')as f:
a=json.load(f)
for i in a:
if(word==i):
print("Word already in dictionery try updating")
break
else:
meaning=input("Enter the meaning :").title()
temp[word]=meaning
for i in a,temp:
temp1.update(i)
with open("words.txt",'w')as m:
json.dump(temp1,m)
elif (choice==4):
print(".....Exit App.....")
elif(choice==3):
temp={}
temp1={}
word=input("Enter the word to update : ").title()
with open("words.txt",'r')as f:
a=json.load(f)
for i in a:
if(word==i):
meaning=input("Enter the meaning : ").title()
temp[word]=meaning
break
else:
print(word,"is not in list try adding")
for i in a,temp:
temp1.update(i)
with open("words.txt",'w')as f:
json.dump(temp1,f)
else:
print("Please choose between above options....")
