-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday 3.py
More file actions
42 lines (27 loc) · 873 Bytes
/
day 3.py
File metadata and controls
42 lines (27 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
while True:
print("\n--- Simple Note Saver ---")
print("1. Add Note")
print("2. View Notes")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == "1":
note = input("Write your note: ")
with open("notes.txt", "a") as file:
file.write(note + "\n")
print("Note saved successfully ✅")
elif choice == "2":
try:
with open("notes.txt", "r") as file:
data = file.read()
print("\n--- Your Notes ---")
if data == "":
print("No notes yet.")
else:
print(data)
except FileNotFoundError:
print("No notes file found yet.")
elif choice == "3":
print("Goodbye 👋")
break
else:
print("Invalid choice ❌ Try again.")