Skip to content

Operation input is not stripped and the rejection message does not repeat the options #10

Description

@dmccoystephenson

Summary

Two small usability gaps around the operation prompt, both reachable with ordinary input:

  1. The input is barely normalized. .upper() is applied to the operation but nothing is stripped, so a leading or trailing space lands in the else. The symbols +, -, *, / and any abbreviation are likewise unrecognized. Neither number prompt is normalized at all.
  2. The rejection message does not repeat the options. "That wasn't an option." gives the user no indication of what the options were, and — because the program exits immediately afterward — no chance to try again without re-running it.

Evidence

Verified this cycle under Python 2.7.18:

$ printf '6\n3\nbanana\n\n' | timeout 10 python calculator.py
What is the first number? What is the second number? Add, Subract, Multiply or Divide? That wasn't an option.

Any key to exit.

Line 3 applies .upper() and nothing else:

whatToDo = (raw_input("Add, Subract, Multiply or Divide? ")).upper()

Suggested fix

.strip() is added alongside the existing .upper(), and the rejection message is extended to name the four accepted keywords. Both are small and confined to existing lines.

Accepting the +, -, *, / symbols would widen what the program's interface accepts and is deliberately not proposed here — that belongs with the keyword decision tracked separately.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions