This code works as intended if valid input is received the first time around. If the input received is incorrect, it will prompt you to try again, and when valid input is finally received it will go on to return 0.
def string_num_query():
string_num = 0
try:
string_num = int(input("Enter number of strings (1-6): "))
if string_num < 1 or string_num > 6:
print("Value must be between 1 and 6.")
string_num_query()
except ValueError:
print("User input must be a number.")
string_num_query()
return string_num
I've tried following the flow of it and just can't see where I've gone wrong. Any help is much appreciated!