Skip to main content
๐Ÿ“œ WAYPOINT LESSON

CLI Menus & Testable Cores

โญ beginnerโณ 12 min read๐Ÿ“ Lesson 51 of 169

The menu loop, input() limits in graders, and separating deciding from doing.

A command-line application is a loop: show options, read a choice, act, repeat.

while True:
    choice = menu()          # in real apps: input("> ")
    if choice == "list":
        show_tasks()
    elif choice == "add":
        add_task()
    elif choice == "quit":
        break
    else:
        print("unknown choice")

input() reads a line from the user โ€” but the sandbox (and any automated grader) cannot type at your program. That is why graded challenges isolate functions with parameters and returns, and menus are wired around them:

def add_task(tasks, text):
    tasks.append({"text": text, "done": False})
    return tasks

Separate the deciding from the doing and your CLI becomes testable โ€” the same lesson the capstone will grade you on.

โšก Now practice

Ready to Code
Task-Function DrillsThe pure logic of a task manager โ€” no menu, just functions.
4 challenges ยท ยท ~30 min