-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkout_tracker.py
More file actions
74 lines (62 loc) · 1.91 KB
/
workout_tracker.py
File metadata and controls
74 lines (62 loc) · 1.91 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
workout_plan = []
print("=== Workout Plan Tracker ===")
def add_exercise():
exercise = input("Enter an exercise (e.g., Leg Extensions 3x10): ")
workout_plan.append(exercise)
print("Exercise added!")
def remove_exercise():
exercise = input("Enter the exact exercise to remove: ")
if exercise in workout_plan:
workout_plan.remove(exercise)
print("Exercise removed!")
else:
print("That exercise is not in your plan.")
def save_plan():
if not workout_plan:
print("Workout plan is empty, nothing to save.")
return
with open("workout_plan.txt", "w", encoding="utf-8") as f:
for exercise in workout_plan:
f.write(exercise + "\n")
print("Workout plan saved to workout_plan.txt")
def load_plan():
if not os.path.exists("workout_plan.txt"):
print("No saved workout plan found.")
return
workout_plan.clear()
with open("workout_plan.txt", "r", encoding="utf-8") as f:
for line in f:
exercise = line.strip()
if exercise:
workout_plan.append(exercise)
print("Workout plan loaded!")
while True:
print("\nChoose an option:")
print("1. Add exercise")
print("2. View workout plan")
print("3. Remove exercise")
print("4. Save workout plan")
print("5. Load workout plan")
print("6. Exit")
choice = input("Enter your choice: ")
if choice == "1":
add_exercise()
elif choice == "2":
print("\nYour workout plan:")
if not workout_plan:
print("- (empty)")
else:
for exercise in workout_plan:
print("-", exercise)
elif choice == "3":
remove_exercise()
elif choice == "4":
save_plan()
elif choice == "5":
load_plan()
elif choice == "6":
print("Goodbye!")
break
else:
print("Invalid option, try again.")