Let’s say you’re asked for input, such as your age, but instead of putting your age in, you accidentally hit ‘enter.’ The program, however, ignores the keystroke and goes to the next step. Your age is not entered but is regarded as empty/null value.
How do you code to fix this problem?
Thank you
With a
whileloop, you do not need to write theinput()function twice:You might also check if the input is an integer and get an integer from the string. An empty string for
agewill also raise aValueErrorexception: