Project 1 - English Dictionary App & Library Book Management System
The aim of this project is to create an English Dictionary app that returns definitions of English words.
import json
choice = 1
while (choice!=4):
choice = int(input('''Main Menu
press 1 for Add New Word
press 2 for Search word
press 3 for Update the Word
press 4 for Exit
Enter the choice :'''))
print('your choice :',choice)
if (choice == 1):
word = input('Enter the word you want to search :').title()
with open ('work.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 = {}
temp = {}
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("word.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")
output: