
![]() |
@wtf | |
Command-line to-do list |
||
1
Replies
12
Views
1 Bookmarks
|
![]() |
@wtf | 27 days |
Mini Project – CLI To-Do List App* You’ll use everything you've learned so far: functions, input/output, lists, and error handling. *What You'll Build:* A simple Command-Line To-Do List where users can: - Add tasks - View tasks - Remove tasks - Exit the app safely *Python Code:* todo_list = [] def show_menu(): print(nTo-Do List Options:) print(1. View Tasks) print(2. Add Task) print(3. Remove Task) print(4. Exit) def view_tasks(): if not todo_list: print(No tasks yet!) else: print(nYour Tasks:) for idx, task in enumerate(todo_list, start=1): print(fidx. task) def add_task(): task = input(Enter the task: ) todo_list.append(task) print(Task added!) def remove_task(): view_tasks() try: index = int(input(Enter task number to remove: )) - 1 removed = todo_list.pop(index) print(fRemoved: removed) except (ValueError, IndexError): print(Invalid task number.) while True: show_menu() choice = input(Choose an option (1-4): ) if choice == 1: view_tasks() elif choice == 2: add_task() elif choice == 3: remove_task() elif choice == 4: print( |
||


