# Storage of tasks #completed and uncompleted tasks.
todo = []
completed_todos = []
# Function that shows stored uncompleted tasks.
def show():
print("\nTASKS")
for i in range(len(todo)):
print(f"{i + 1}. {todo[i]}")
# Function that adds(store) a task to a list todo[].
def add(task):
todo.append(task)
print(f"You have added '{task}' successfully.")
task = input("\ntype 'exit' to exit. \nAdd new task: ")
# If user want to stop adding task they just type 'exit'.
if task == "exit":
to_do()
else:
add(task)
# Function that used to remove tasks.
def remove(del_no):
print(f"Your task '{todo[del_no - 1]}' has deleted successfully.")
todo.pop(del_no - 1)
# len(todo) > 0 checks if there is a task in a list to delete. If task is not in it goes to the first page.
if len(todo) > 0:
show()
new_del_no = input("type 'exit' to exit. \nAnother task to remove: ")
if new_del_no == "exit":
exit(new_del_no)
else:
remove(int(new_del_no))
# Function used to store completed tasks and remove it from uncompleted tasks.
def complete(to_complete):
print(f"You completed your task '{todo[to_complete - 1]}'. Good Job!")
completed_todos.append(todo[to_complete - 1])
# pop() deletes the task
todo.pop(to_complete - 1)
if len(todo) > 0:
show()
new_task_to_complete = input("enter 'exit' to exit. \nAnother task to complete? ")
if new_task_to_complete == "exit":
exit(new_task_to_complete)
else:
complete(int(new_task_to_complete))
# Function used to show completed tasks.
def completed_tasks():
print("\nCOMPLETED TASKS")
for n in range(len(completed_todos)):
print(f"{n + 1}. {completed_todos[n]}")
# Function that returns completed tasks to uncompleted task. If user touched completed without knowing.
def uncomplete(retrieve_completed):
todo.append(completed_todos[retrieve_completed - 1])
completed_todos.pop(retrieve_completed - 1)
if len(completed_todos) > 0:
completed_tasks()
another_to_uncomplete = input("'exit' to exit. \nAnother task to uncomplete? ")
if another_to_uncomplete == "exit":
exit(another_to_uncomplete)
else:
uncomplete(int(another_to_uncomplete))
# Fuction that helps user if he want to exit at anytime.
def exit(exit):
if exit == "exit":
to_do()
#
def to_do():
doing_task = True
while doing_task:
# Asks user what to do
action = input("\n1. Add \n2. Remove \n3. Show \n4. Complete \n5. Completed tasks \nWhat do you want to make: ")
# '1' is for adding task
if action == "1":
task = input("Add your task: ")
add(task)
# If user wants to remove task input '2'.
elif action == "2":
if len(todo) > 0:
show()
del_no = input("\nEnter 'exit' to exit. \nWhich task number do you want to remove? ")
exit(del_no)
remove(int(del_no))
else:
print("\tEmpty tasks. Please add tasks to delete.")
# If user wants to see his tasks he choose number '3'.
elif action == "3":
if len(todo) > 0:
show()
else:
print("\tThere is no task to show.")
# If user want move his task to completed lists he chooses '4'.
elif action == "4":
if len(todo) > 0:
show()
to_complete = input("\nEnter 'exit' to exit. \nWhich task you are going to complete: ")
exit(to_complete)
complete(int(to_complete))
else:
print("\tEmpty tasks. Please add tasks")
# If user want to see the completed task and uncomplete he chooses '5'.
elif action == "5":
if len(completed_todos) > 0:
completed_tasks()
task_to_uncomplete = input("enter 'exit' to exit. \nTask you didn't completed? ")
exit(task_to_uncomplete)
uncomplete(int(task_to_uncomplete))
else:
print("\tNo completed task yet.")
# If user not enter another input
else:
print("Error input.")
doing_task = False
# Calling the function
to_do()