Making Notes In Python Code
class NotetakingApp:
def __init__(self):
self.notes = {}
def create_note(self):
title = input("Enter the title of the note: ")
content = input("Enter the content of the note: ")
self.notes[title] = content
print("Note created successfully!")
def view_note(self):
title = input("Enter the title of the note to view: ")
if title in self.notes:
print("Title: ", title)
print("Content: ", self.notes[title])
else:
print("Note not found!")
def edit_note(self):
title = input("Enter the title of the note to edit: ")
if title in self.notes:
new_content = input("Enter the new content of the note: ")
self.notes[title] = new_content
print("Note edited successfully!")
else:
print("Note not found!")
def delete_note(self):
title = input("Enter the title of the note to delete: ")
if title in self.notes:
del self.notes[title]
print("Note deleted successfully!")
else:
print("Note not found!")
def list_notes(self):
print("List of notes:")
for title in self.notes:
print(title)
def run(self):
while True:
print("\nNote-taking App")
print("1. Create a note")
print("2. View a note")
print("3. Edit a note")
print("4. Delete a note")
print("5. List all notes")
print("6. Quit")
choice = input("Enter your choice: ")
if choice == "1":
self.create_note()
elif choice == "2":
self.view_note()
elif choice == "3":
self.edit_note()
elif choice == "4":
self.delete_note()
elif choice == "5":
self.list_notes()
elif choice == "6":
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
app = NotetakingApp()
app.run()