preferred method:
okay=False
depth=0
def dcheck():
global depth
global okay
while not okay:
try:
depth=int(input('Enter depth in range(0,50): '))
if depth in range(0,51):
print(depth)
okay=True
return okay
else:
print('Invalid Depth')
okay=False
except:
print('Invalid input')
dcheck()