Sign in to test your solution.
# Notebook program # ------------------------- # Subprograms # ------------------------- def get_note_number(): valid_input = False while not valid_input: note_number = int(input("Note number: ")) if note_number >= 0 and note_number < 10: valid_input = True else: print("Invalid input. Enter 0-9.") return note_number def add_note(): index = get_note_number() note = input("Enter the note: ") notebook[index] = note def clear_notes(): choice = "" while choice not in ["y", "n"]: choice = input("Are you sure you want to delete all notes? y/n :") if choice == "y": for index in range(len(notebook)): notebook[index] = "" def order_notes(): notebook.sort() def show_notebook(): for index in range(len(notebook)): print(index, ":", notebook[index]) def menu(): print() print("a. Add note") print("c. Clear notebook") print("o. Order notes") print("q. Quit") choice = input(":") if choice == "q": return False match choice: case "a": add_note() case "c": clear_notes() case "o": order_notes() return True # ------------------------- # Main program # ------------------------- notebook = ["" for note in range(10)] running = True while running: show_notebook() running = menu()

  Python sandbox

This window allows you to run Python code without installing a thing. The code you write here is not automatically submitted to Dodona.

Test case being debugged