import json
def load_notes_from_file():
try:
with open("[Link]", "r") as file:
return [Link](file)
except FileNotFoundError:
return {}
def add_note(notes):
title = input("Enter the title of the note: ")
content = input("Enter the content of the note: ")
notes[title] = content
print("Note added successfully.")
def view_notes(notes):
if not notes:
print("No notes added yet.")
else:
print("Current Note Titles:")
for title in [Link]():
print(title)
def view_note_content(notes):
note_title = input("Enter the title of the note you want to view: ")
if note_title in notes:
print(f"{note_title}: {notes[note_title]}")
else:
print("No note found with this title.")
def delete_note(notes):
title = input("Enter the title of the note you want to delete: ")
if title in notes:
del notes[title]
print("Note deleted successfully.")
else:
print("No note found with this title.")
notes = load_notes_from_file()
while True:
print("\nPlease select an action:")
print("1. Add Note")
print("2. View Notes")
print("3. View Note")
print("4. Delete Note")
print("5. Exit")
choice = input("Enter your choice (1/2/3/4/5): ")
if choice == '1':
add_note(notes)
elif choice == '2':
view_notes(notes)
elif choice == '3':
view_note_content(notes)
elif choice == '4':
delete_note(notes)
elif choice == '5':
print("Exiting the program...")
with open("[Link]", "w") as file:
[Link](notes, file)
break
else:
print("Invalid input, Please try again!")