Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Add_subject():
- try:
- subject = input("Which subject do you want to add:")
- with open("subjects.txt","a") as file:
- file.write(subject + "\n")
- with open("subjects.txt","r") as file:
- subjects = file.read()
- print("Subject added successfully")
- except Exception as e:
- print("Error",e)
- def Remove_subject():
- try:
- with open("subjects.txt","r") as file:
- subjects = file.read().splitlines()
- for i, subject in enumerate(subjects, start=1):
- print(f"{i}:{subject}")
- remove = int(input("Which subject to remove(1/2/3, etc):"))
- index = remove - 1
- if remove > len(subjects):
- print("Subject does not exist")
- else:
- subjects.pop(index)
- with open("subjects.txt","w") as file:
- for s in subjects:
- file.write(s + "\n")
- except Exception as e:
- print("Error:",e)
- def View():
- try:
- with open("subjects.txt","r") as file:
- subjects = file.read().splitlines()
- for i,subject in enumerate(subjects,start=1):
- print(f"{i}.{subject}")
- except Exception as e:
- print("Error:",e)
- def Chapters():
- try:
- with open("subjects.txt","r") as file:
- subjects = file.read().splitlines()
- for i, subject in enumerate(subjects, start=1):
- print(f"{i}:{subject}")
- add = int(input("Which subject to add chapters to(1/2/3, etc):"))
- if add > len(subjects):
- print("Subject does not exist")
- while True:
- print("\nStudy Tracker\nWhat operation do you want to do?\n\n1.Add subject\n2.Remove subject\n3.View subjects\n4.Add/remove chapters\n5.Add/remove notes for subjects\n6.View chapters and notes\n7.log study sessions\n8.View progress\n9.Calculator(for math)\n")
- choice = input("Enter your choice:")
- if choice not in ["1","2","3","4","5","6","7"]:
- print("Enter a valid choice")
- continue
- if choice == "1":
- Add_subject()
- elif choice == "2":
- Remove_subject()
- elif choice == "3":
- View()
Advertisement
Add Comment
Please, Sign In to add comment