Validating Input

However clear we make our program's instructions users will always find ways to make mistakes. To avoid using inappropriate data that might crash our program we should validate the data that is input. The while statement is perfect for this job:

Python code that demonstrates validating input.

Extension challenge: How would you modify this code to give the user at most 3 chances to enter acceptable data?