Validation With Iteration
Need more help with iteration? Click here
Need more help with validation? Click here
In the modify tasks, you are given some starter code.
Use the instructions below to make changes to the code.
Comment your changes to explain what you have done.
Adapt the code so that:
- It asks the user to enter a the number of the month they were born (example: input 1 for January.)
- It validates the input against a sensible range and gives the user a chance to try again.
- It outputs a suitable error message if the user inputs a number that is too large.
- It outputs a suitable error message if the user inputs a number that is too small.
- Outputs a suitable message when input is accepted.
Help! My code doesn’t work
Make sure that you check for the following things:
- Not getting input before the loop starts
- No colon at the end of the loop condition
- Not getting input again inside the loop
- Not using the same variable to store input inside the loop
- Not indenting the code that belongs inside the loop
- Indenting the success message to make it part of the loop