Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dictionary.py #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
52 changes: 26 additions & 26 deletions dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@ def __init__(self, word, 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 the Dictionary. Please 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 the 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 the Dictionary, Please Make Sure Spellings are Correct?")

def view_all(self):
for i in dictionary.keys():
print(i + " : " + dictionary[i])
def view_all(self):
for i in dictionary:
print(i ," : ", dictionary[i])

def start():
get_op = raw_input("Add, Delete, Edit, View, View all : ")
get_op = input("Add, Delete, Edit, View, View all : ")
if get_op in ["add", "Add"]:
get_word = raw_input("Word to add : ")
get_meaning = raw_input("Meaning : ")
get_word = input("Word to add : ")
get_meaning = input("Meaning : ")
new = Dict(get_word, get_meaning)
new.add_new()

elif get_op in ["delete", "Delete"]:
get_word_to_del = raw_input("Word to delete : ")
elif get_op in ["delete", "Delete", "DELETE"]:
get_word_to_del = input("Word to delete : ")
delete = Dict(get_word_to_del, None)
delete.delete_word()

elif get_op in ["edit", "Edit"]:
get_word_to_edit = raw_input("Word to edit : ")
get_new_meaning = raw_input("New meaning : ")
get_word_to_edit = input("Word to edit : ")
get_new_meaning = input("New meaning : ")
mean = Dict(get_word_to_edit, get_new_meaning)
mean.edit_word()
mean.edit_word()

elif get_op in ["view", "View"]:
get_word_to_view = raw_input("Word to view : ")
elif get_op in ["view", "View", "VIEW"]:
get_word_to_view = input("Word to view : ")
view = Dict(get_word_to_view, None)
view.view_word()

Expand All @@ -64,22 +64,22 @@ def start():
nothing.view_all()

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

def end():
quit()

def main():
while True:
s_or_e = raw_input("Start or End : ")
if s_or_e == "Start":
s_or_e = input("Start or End : ")
if s_or_e == "Start" | s_or_e == "start":
start()
print(" ")
continue

else:
end()
end()


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