0% found this document useful (0 votes)
26 views2 pages

Note Management System in Python

This document is a Python script for a note-taking application that allows users to add, view, delete, and manage notes stored in a JSON file. It includes functions for loading notes from a file, adding new notes, viewing existing notes and their content, and deleting notes. The application runs in a loop until the user chooses to exit, at which point it saves the notes back to the JSON file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Note Management System in Python

This document is a Python script for a note-taking application that allows users to add, view, delete, and manage notes stored in a JSON file. It includes functions for loading notes from a file, adding new notes, viewing existing notes and their content, and deleting notes. The application runs in a loop until the user chooses to exit, at which point it saves the notes back to the JSON file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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!")

You might also like