Python_ToDoApp/main.py

55 lines
1.9 KiB
Python

# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
#def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
# print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
#if __name__ == '__main__':
# print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
# -----------------------------------------------------------------
todos = []
command_prompt = "Type add, show, edit, complete, or exit: "
todo_prompt = "Enter a todo: "
edit_prompt = "Number of todo to edit: "
complete_prompt = "Which todo to mark complete: "
edit_todo = "Enter new todo: "
todo_length = len(todos)
while True:
user_action = input(command_prompt)
user_action = user_action.strip()
match user_action:
case 'add':
todo = input(todo_prompt)
todo = todo.capitalize()
todos.append(todo)
case 'show' | 'display':
for i, todo in enumerate(todos):
text = f"{i}: {todo}"
print(text)
case 'edit':
which_todo = int(input(edit_prompt)) - 1
new_todo = input(edit_todo)
todos[which_todo] = new_todo
case 'complete':
completed = int(input(complete_prompt)) - 1
completed_message = f"'{todos[completed]}' has been completed!"
print(completed_message)
todos.pop(completed)
print("Remaining todos: ")
for i, todo in enumerate(todos):
text = f"{i}: {todo}"
print(text)
case 'exit':
break
case _:
print("Unrecognized command; please try again.")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Goodbye!")