Input Validation
I'm hoping to learn how to validate a user's input. I'd like the code to ask for an input; the user enter an input, in this case Y/N or just enter. If the user enter's a valid value then the code will continue to run, however, if the user does not enter a valid input, the code will return an error message and then offer additional chances to enter a valid input. I considered a 'while loop,' but I was hoping to write something more efficient. Here is what I am trying, it doesn't work because once the AssertionError is triggered, the code stops entirely. def section_addition(): #asks user if they are ready to begin the addition lesson ready_addition = input("Are you ready (Y/N)? ").lower() or "-" assert(ready_addition[0] == "y" or ready_addition == "-" or ready_addition[0] == "n"), "Enter Y or N."