I have just read some questions about when to use exception handling. And a question came up, from these 2, which one is better?
def get_ans(q):
while True:
x = input(q)
if x.isdigit():
return int(x)
or
def get_ans(q):
while True:
try:
return int(input(q))
except ValueError:
pass