-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The current voting eligibility program handles ValueError for non-numeric input. However, it does not properly handle some edge cases such as:
Negative age values
Extremely large unrealistic ages
Zero as input
Blank input
This may lead to incorrect logical output (e.g., negative wait years).
If the user enters:
-5 → Output becomes: Wait 23 more years ❌
0 → Logic technically works but may need validation
150 → No upper bound validation
✅ Expected Behavior
Age should not be negative.
Age should have a reasonable upper limit (e.g., 120).
Program should show a proper error message for invalid age ranges.
Improve user input validation for better robustness.💡 Suggested Improvement
Add range validation inside the try block:
if age < 0 or age > 120:
print("Please enter a realistic age between 0 and 120.")
🎯 Acceptance Criteria
Prevent negative age input
Prevent unrealistic age input
Maintain existing ValueError handling
Clean and readable code
you can find the code in voting.py file