Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions dictionary.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@

global dictionary

dictionary = {}


class Dict:
def __init__(self, word, meaning):
self.word = word
self.meaning = meaning

def add_new(self):
dictionary[self.word] = self.meaning
print "Word Successfully Added"
print("Word Successfully Added")

def delete_word(self):
try:
del dictionary[self.word]
print "Word Successfully Deleted"
print("Word Successfully Deleted")
except KeyError:
print "The Word Does Not Exist in Dictionary. Try Again!"
print("The Word Does Not Exist in Dictionary. Try Again!")

def edit_word(self):
try:
dictionary[self.word] = self.meaning
print "Word Was Successfully Edited"
print("Word Was Successfully Edited")
except KeyError:
print "The Word You Trying To Edit Does Not Exist in Dictionary!"
print("The Word You Trying To Edit Does Not Exist in Dictionary!")

def view_word(self):
try:
print dictionary[self.word]
print(dictionary[self.word])
except KeyError:
print "The Word is not in Dictionary."
print("The Word is not in Dictionary.")

def view_all(self):
for i in dictionary.keys():
Expand Down Expand Up @@ -64,7 +66,7 @@ def start():
nothing.view_all()

else:
print "Invalid Input. Try again!"
print("Invalid Input. Try again!")

def end():
quit()
Expand All @@ -82,4 +84,4 @@ def main():


if __name__ == "__main__":
main()
main()