Challenge

Project 1 - English Dictionary App & Library Book Management System

this is my first project

plz Guide me

if any error

plz guide me in starting point

print( '''WELCOME TO MY DICTIONARY APPLICATION!''')
print('1.Add a new word')
print('2.Find the Meaning')
print('3.Update the word')
print('4.Exit')
import pickle
import os
def saveDictionary(my_dict):
'''
This function recives a python dictionary,
and saves it to a serialized file words.txt
'''
try:
with open('words.txt', 'wb') as dictionary:
pickle.dump(my_dict, dictionary)
'''dictionary = open('words.txt', 'wb')
# pickle.dump(my_dict, dictionary)
# dictionary.close()'''
print("SUCCESS: writing to dictionary words.txt")
except Exception as e:
print(f"ERROR: {e}")


def getDictionary():
'''
This function returns a python dictionary,
after de-serializing the file words.txt
'''
try:

with open('words.txt', 'rb') as dictionary:
my_dict = pickle.load(dictionary)
print("SUCCESS: reading from dictionary words.txt")
return my_dict
except Exception as e:
print(f"ERROR: {e}")


#2. User-Software Interface

def add_New_Word():
'''
This function provides functionalities for n==1,
that is, it creates a new word in the dictionary
'''
print("__________")
print("NEW WORD ADDER:")
print("__________")
print("Enter a Word to add")
word = input(">>")
print(f"Enter a meaning of {word} to add")
meaning = input(">>")
dictionary = getDictionary()
dictionary[word] = meaning
saveDictionary(dictionary)


main_menu()


def find_Meaning():
'''
This function provides functionalities for n==2,
that is, it finds a word in the dictionary
'''
print("__________")
print("WORD FINDER:")
print("__________")
print("Enter a Word to find")
word = input(">>")
dictionary = getDictionary()

if word in dictionary:
print(f"Found_Entry: [{word} : {dictionary[word]}]")
else:

print("ERROR: The word doesn't exist!")
findMeaning()


main_menu()


def update_Word():
'''
This function provides functionalities for n==3,
that is, it updates a word in the dictionary
'''
print("__________")
print("WORD UPDATER:")
print("__________")
print("Enter an old Word to edit")
word = input(">>")

dictionary = getDictionary()
if word in dictionary:
print(f"Enter a New Meaning to edit [{word} : {dictionary[word]}] to:")
new_meaning = input(">>")
dictionary[word] = new_meaning
saveDictionary(dictionary)
print(f"SUCCESS: Updated to [{word} : {dictionary[word]}]")
else:

print("ERROR: The word doesn't exist! impossible to update!")
updateWord()


main_menu()


def main_menu():
'''
This function prints Main Menu:
__________
ENGLISH DICTIONARY APP
__________
1. Add a new word
2. Find the meaning
3. Update a word
4. Exit
__________
'''
if not os.path.exists(os.path.join("words.txt")):
try:
with open('words.txt', 'wb') as dictionary:
pickle.dump({}, dictionary)
print("SUCCESS: writing to dictionary words.txt")
except Exception as e:
print(f"ERROR: {e}")
print("__________")
print("ENGLISH DICTIONARY APP")
print("__________")
print("1. Add a new word")
print("2. Find the meaning")
print("3. Update a word")
print("4. Exit")
print("__________")

n = int(input(">>"))
if n==1:

add_New_Word()
elif n==2:

find_Meaning()
elif n==3:
update_Word()
elif n==4:
exit()
else:

print("ERROR: Please Enter a digit according to Menu.")
main_menu()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.