Skip to content

Merge fix/sanitize into main for lab_1b.py#163

Open
ysaanvi19-boop wants to merge 6 commits intoMIT-BWSI-CSS:mainfrom
ysaanvi19-boop:fix/sanitize
Open

Merge fix/sanitize into main for lab_1b.py#163
ysaanvi19-boop wants to merge 6 commits intoMIT-BWSI-CSS:mainfrom
ysaanvi19-boop:fix/sanitize

Conversation

@ysaanvi19-boop
Copy link

Sanitized user input for numbers and operations

Copy link
Author

@ysaanvi19-boop ysaanvi19-boop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on error handling in sanitize function

number = float(input(prompt))
return number
except ValueError:
print("Invalid input. Please enter a valid number.")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValueError may catch a few errors in a limited scope - try catching all the exceptions then printing the error instead.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant