Project 1 English Dictionary App
import json
underline = '33[4m'
print(underline+'Main Menu')
No_underline = '33[m'
def menu():
print(No_underline+' 1. Add a new word')
print(No_underline+' 2. Find the meaning')
print(No_underline+' 3. Update a word')
print(No_underline+' 4. Exit')
menu()
print()
choice = int(input(' Enter choice: '))
def choice_1():
print('choice 1 has been called')
dictionary = {'programming':'Set of code or rules that will be ran by a computer.'}
f = open('words.txt','w')
json.dump(dictionary,f)
f.close()
def choice_2():
print('choice 2 has been called')
f = open('words.txt','r')
dictionary = json.load(f)
search = input('Enter a word :').casefold()
if search in dictionary:
word = search.title()
print('{}:{}'.format(word, dictionary[search]))
else:
print('The meaning of the word entered is not found')
def choice_3():
print('choice 3 has been called')
dictionary1 = {'Python':'It is a general purpose for programming language.'}
f = open('words.txt','w')
json.dump(dictionary1,f)
f.close()
while choice !=4:
if choice == 1:
choice_1()
elif choice == 2:
choice_2()
elif choice == 3:
choice_3()
else:
print('Invalid choice number')
print()
menu()
print()
choice = int(input(' Enter choice: '))
print('Thank you for using this program. Goodbye.')