Skip to content

[Bug] Tower-of-Hanoi crashes with ValueError on START when disk field is empty/non-numeric #1870

Description

@vedant7007

Problem (Med — crash on START)

utilities/Tower-of-Hanoi/Tower-of-Hanoi.py:49:

num_disks = int(disk_entry.get())

has no validation. Clicking START with the entry empty (its default) or containing non-numeric text raises an uncaught ValueError in the Tk callback — a traceback is dumped to the console and the game never starts. Trivially reproducible on first launch.

Suggested fix (small)

Wrap in try/except ValueError, validate num_disks >= 1, and show a feedback-label message instead of throwing.

Glad to fix under GSSoC '26.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions