Issue is when I test my error handling, entering the unexpected inputs multiple times and then proceeding to enter the acceptable number of lines to bet on the return is recived as "None" the variable seems to not stay stored or is somehow over written. Any Ideas? I would place the other half of the code but am forced to type everything due to company policies. I apologize for any inconvenience, I thank everyone for ther time in viewing this post.
MAX_LINES = 3
def get_number_of_lines():
try:
while True:
lines = ("Enter the number of lines to be on (1-" + str(MAX_LINES) + ")? ")
if lines.isdigit:
lines = int(lines)
if 1 <= lines <= MAX_LINES:
break
else:
print("Enter a valid number of lines.")
return lines
except ValueError:
print("Please enter a number. ")
get_number_of_lines()
def main():
lines = get_number_of_lines()
print(lines)
Expected the number entered 1-3 to be printed from the return line even if moved from and to the except statment.