-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinalProject.py
More file actions
66 lines (54 loc) · 1.85 KB
/
FinalProject.py
File metadata and controls
66 lines (54 loc) · 1.85 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
task_list = []
running = True
def add_new_task(taskList, new_task):
"""adds a new task to the passing parameter list"""
taskList.append(new_task)
print(f"{new_task} added with success.")
def delete_task(task_list, task_to_delete):
if not task_to_delete.isnumeric():
print("Please enter a valid number.")
elif int(task_to_delete) > len(task_list):
print("Please enter a valid number.")
elif int(task_to_delete) <= 0:
print("Please enter a valid number.")
else:
task_list.pop(int(task_to_delete))
print(f"Task number + {int(task_to_delete)} has been deleted.")
def list_tasks(taskList):
"""list all tasks store in passing task list"""
print("*" * 50)
print(f"Task List {taskList}")
print("_" * 50)
n=1
for task in taskList:
print (f"{n} - {task}")
n+=1
def show_menu():
"""shows terminal menu and returns entered option by user"""
print("\nChoose an option: \n"
"1 - Enter a new task\n"
"2 - List tasks\n"
"3 - Delete task\n"
"4 - Leave \n")
return input("Enter a number to choose: ")
while running:
chosen_option = show_menu()
if chosen_option == "1":
"""Add new task"""
newTask = input("Enter new task name: ")
add_new_task(task_list, newTask)
elif chosen_option == "2":
"""List Tasks"""
print("\nTask List")
for task in task_list:
print(f"* {task}")
elif chosen_option == "3":
"""Delete Task"""
task_to_delete = input("Enter task number to delete it: ")
delete_task(task_list, task_to_delete)
elif chosen_option == "4":
"""Exit terminal"""
running = False
else:
print("Invalid option, enter a valid option number")