I'm trying to write a code to edit a list and make it a palindrome.
Everything is working except my input still gives me one error. When I enter a non-int into get_number_2, it crashes.
def get_number():
num = raw_input("Please enter number between 100,000 and 1,000,0000: ")
if not num.isdigit():
print "---------------------------"
print "Invalid input: numbers only"
print "---------------------------"
my_main()
else:
return num
def get_number_2(n):
num = input("Please confirm the number you have entered: ")
if num != int(n):
print "--------------------"
print "Entries do not match"
print "--------------------"
my_main()
else:
return num
I use the input from get_number_2 for the rest of the code as get_number doesn't work when I check if its between two numbers.
Is there any way i can validate if input is an int in get_number_2 so that I can get rid of get_number?