-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_list.py
75 lines (56 loc) · 1.83 KB
/
task_list.py
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
tasks = [
{ "description": "Wash Dishes", "completed": False, "time_taken": 10 },
{ "description": "Clean Windows", "completed": False, "time_taken": 15 },
{ "description": "Make Dinner", "completed": True, "time_taken": 30 },
{ "description": "Feed Cat", "completed": False, "time_taken": 5 },
{ "description": "Walk Dog", "completed": True, "time_taken": 60 },
]
# MVP
## Get list of uncompleted tasks
def get_uncompleted_tasks(list):
uncompleted_tasks = []
for task in list:
if task["completed"] == False:
uncompleted_tasks.append(task)
return uncompleted_tasks
## Get list of completed tasks
def get_completed_tasks(list):
completed_tasks = []
for task in list:
if task["completed"] == True:
completed_tasks.append(task)
return completed_tasks
## Refactor get_uncompleted_tasks and get_completed_tasks
def get_tasks_by_status(list, status):
tasks = []
for task in list:
if task["completed"] == status:
tasks.append(tasks)
return tasks
## Get tasks where time_taken is at least a given time
def get_tasks_taking_longer_than(list, time):
tasks = []
for task in list:
if task["time_taken"] >= time:
tasks.append(task)
return tasks
## Find any task with specific description
def get_task_with_description(list, description):
for task in list:
if task["description"] == description:
return task
return "Task Not Found"
def mark_task_complete(task):
task["completed"] = True
# Extensions
# create a task
def create_task(description, time_taken):
task = {}
task["description"] = description
task["completed"] = False
task["time_taken"] = time_taken
return task
# add a task to the list
def add_to_list(list, task):
list.append(task)
# create a menu