How do I use try .. except or if ...else to validate user input?
I'd suggest a combination:)
while True:
value = raw_input('Value between 0 and 100:')
try:
value = int(value)
except ValueError:
print 'Valid number, please'
continue
if 0 <= value <= 100:
break
else:
print 'Valid range, please: 0-100'
Hope it helps.
if/else is probably more appropriate here, since any exceptions raised would be ones you threw yourself (and you'd still have to handle them).