From 812e1819c6f8f5b8fb3d2fe27d54dece86cfea25 Mon Sep 17 00:00:00 2001 From: Pro-Hanad Date: Tue, 12 May 2026 11:31:18 +0530 Subject: [PATCH] Assignment 2 --- .../HanadIsmail/assignment-2/study_log.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 submissions/HanadIsmail/assignment-2/study_log.py diff --git a/submissions/HanadIsmail/assignment-2/study_log.py b/submissions/HanadIsmail/assignment-2/study_log.py new file mode 100644 index 0000000..8f4ea52 --- /dev/null +++ b/submissions/HanadIsmail/assignment-2/study_log.py @@ -0,0 +1,47 @@ + +# study_log.py +# Name: Hanad Ismail +# Simple study log program + + + +def load_notes(path): + try: + with open(path, "r", encoding="utf-8") as f: + return [line.strip() for line in f] + except FileNotFoundError: + return [] + + +def save_notes(path, notes): + with open(path, "w", encoding="utf-8") as f: + for n in notes: + f.write(n + "\n") + + +def main(): + notes = load_notes("notes.txt") + + while True: + print("\n1 Add 2 List 3 Quit") + choice = input("Pick: ") + + if choice == "1": + note = input("Note: ") + notes.append(note) + + elif choice == "2": + for n in notes: + print(n) + + elif choice == "3": + save_notes("notes.txt", notes) + print("Bye!") + break + + else: + print("Invalid") + + +if __name__ == "__main__": + main() \ No newline at end of file