I'm trying to write a program where the user inputs a two-digit integer and the output is the second digit printed the amount of times indicated by the first digit. Here is what I have so far:
number = input('Type two-digit integer \n')
a = int(number)//10
b = int(number)%10
if len(number) != 2:
print(number, 'is not a two-digit integer')
else:
print(a*str(b))
When I test this out it does what I intend it to do as long as someone types in numbers. If someone were to type in, say, 6r, an error message would pop up saying:
a = int(number)//10
ValueError: invalid literal for int() with base 10: '6r'
So I would assume that something would need to be put in the second line of the code to test if the input is actually an integer, how would I do that? Would I be better off rewriting it in a different way? Please keep in mind that I'm taking an intro course to Python and this is a question on a practice midterm I am taking, so in the case that I would have to answer something like this on the real midterm I can't use a lot of complicated processes.
This is something I tried that works if someone types something that isn't an integer, but for some reason that I don't know it gives the same message for non-integers to integers and doesn't function as I intend it to:
number = input('Type two-digit integer \n')
if (isinstance(number, int)) == False:
print(number, 'is not a two-digit integer')
elif len(number) != 2:
print(number, 'is not a two-digit integer')
else:
a = int(number)//10
b = int(number)%10
print(a*str(b))
Help would be greatly appreciated!