I'm a student doing a computer science course and for part of the assessment we have to write a program that will take 10 digits from the user and used them to calculate an 11th number in order to produce an ISBN. The numbers that the user inputs HAVE to be limited to one digit, and an error message should be displayed if more than one digit is entered. This is the code that I am using:
print('Please enter your 10 digit number')
a = int(input("FIRST NUMBER: "))
aa = (a*11)
if len(a) > 1:
print ("Error. Only 1 digit allowed!")
b = int(input("SECOND NUMBER: "))
bb = (b*10)
if len(a) > 1:
print ("Error. Only 1 digit allowed!")
ect.
I have to keep the inputs as integers so that some of the calculations in the rest of the program work, but when I run the program, an error saying "object of type 'int' has no len()". I'm assuming that it is referring to the fact that it is an integer and has no length. Is there any way that I can keep 'a' as an integer but limit the length to 1 digit?
(Also I understand that there is probably a more efficient way of writing the program, but I have a fairly limited knowledge of python)