What I\'m trying to do is ask users for two inputs, if one of the inputs is less than zero or if the input is some string then ask for the inputs again. The only valid input are
The solution is to coerce the answer to int() and catch any exceptions, for example:
while True:
try:
number_of_books = int(raw_input('Enter number of books:'))
if number_of_books < 0:
raise ValueError('must be greater than zero')
except ValueError, exc:
print("ERROR: %s" % str(exc))
continue
break
Probably you should put this in a function, and make the prompt a variable (to allow re-use).