-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskTracker.py
More file actions
82 lines (59 loc) · 2.26 KB
/
taskTracker.py
File metadata and controls
82 lines (59 loc) · 2.26 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
75
76
77
78
79
80
81
82
# Code compiled by Sam_Githinji
from prettytable import PrettyTable
from datetime import date
import time
extension = '.txt'
current_date = date.today()
current_date_str = str(current_date)
file_name = current_date_str + extension
print('-----------------------------------------------------')
print(' SG Task List Tracker v1.1')
print('-----------------------------------------------------')
user_name = input('Enter Your Name: ')
try:
file = open(file_name, "r")
except FileNotFoundError:
file = open(file_name, "x")
print(user_name + "'s Tasks for today")
instructions = '\ni.Add:a to add new Task.' \
'\nii.List_Check:l to check your Task List.' \
'\niii.Exit:e to exit the program.'
print(instructions)
my_Task_list = []
x = PrettyTable()
def my_list():
x.field_names = ["Item Names"]
for i in my_Task_list:
x.add_row([i])
print(x.get_string(title='TO DO LIST'))
x.clear_rows()
running = True
while running:
user_input = input('\nWhat do you want to do? (A, L, E): ').lower()
if user_input == 'a':
duration = input(str('\nEnter start and end time: '))
new_Task = input('\nPlease enter your new Task: ').lower()
newTaskDetails = input('\nInput the Task details: ').lower()
print(f'\nYour current Task is {new_Task}.')
my_Task_list.append(new_Task)
file = open(file_name, "a")
file.write(f"\n{user_name},\n{duration}, \n{new_Task}, \n{newTaskDetails}")
file.close()
elif user_input == 'l':
my_list()
file = open(file_name, "r")
print(file.read())
file.close()
elif user_input == 'e':
ask_user = input(user_name + ', are you sure you want to exit? (Y/N): ').lower()
if ask_user == 'y':
running = False
elif user_input == '' or user_input == ' ':
print('Please enter something.')
else:
print('Enter valid letters!')
print('-----------------------------------------------------')
print(' Sam G Task List Tracker v1.1, 2022')
print('-----------------------------------------------------')
print('You are now exiting the program, Goodbye ' + user_name + '!')
time.sleep(3)