Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exit = False
- todo_items = []
- def get_argument(command):
- command_name, argument = command.split(" ", maxsplit=1)
- return argument
- def handle_add_command(command):
- argument = get_argument(command)
- print(f"Adding task: {argument}")
- todo_items.append(argument)
- def handle_delete_command(command):
- argument = get_argument(command)
- print(f"Deleting task: {argument}")
- todo_items.pop(int(argument) - 1)
- def handle_list_command():
- index = 0
- for todo_item in todo_items:
- index += 1
- print(f"{index}. {todo_item}")
- def process_command(command):
- exit = False
- if command.startswith("exit"):
- exit = True
- elif command.startswith("add"):
- handle_add_command(command)
- elif command.startswith("delete"):
- # delete task
- handle_delete_command(command)
- elif command.startswith("list"):
- handle_list_command()
- else:
- print("Command not recognized")
- return exit
- while not exit:
- command = input("Enter command: ")
- exit = process_command(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement