I'm writing a function in Python where I take user input and validate it. Later I'm saving it to a variable using return. But after calling the variable, it says variable not defined.
def user_input():
position = 'wrong'
position_range = range(1,10)
within_range = False
while position.isdigit == False or within_range == False:
position=input('select the postion from (1-10): ')
if position.isdigit()==False:
print('hey! thats not a valid input')
elif position.isdigit()==True:
if int(position) in position_range:
within_range=True
else:
print('hey! thats out of range')
within_range=False
return int(position)
user_input()
print(position)