I need to limit the number of invalid inputs allowed so that after the given amount of tries the program exits.
invalid is defined by the input being less than zero.
the number of attempts let say is 3
so for instance
- Code: Select all
number = float(input('please enter a number (must be greater thatn zero): '))
if number >= 0 :
print ('you choose number:', number)
print ('invalid input')
how would I limit the number of invalid input attempts and make it
so that the code would return to asking the question again and prompt for input
but still keep track of previous attempts?