我目前无法从一个数字中提取一个数字并将其相乘。这是我的密码:
Ask for the users INPUT
do they want to check an 8-digit number or generate a check digit from a 7-digit number?
print("Welcome to the Barcode Scanner. There are two options: ")
print("Do you want to check an 8-digit or generate a check digit from a 7 digit number?")
usersDecision = input("Press 7 to generate the 7th digit, or press 8 to check an 8 digit number")
Get the user to INPUT their 7 or 8 digit number
if usersDecision == "7":
print("You have chosen to generate a check digit from a 7 digit number?")
seven_digitCheck = input("Please enter your 7-digit number")
elif usersDecision == "8":
print("You have chosen to check the validity of an 8 digit number.")
eight_digitValid = input ("Please enter your 8 digit number")
else:
print("This is not a valid option, Please leave")
Get the first digit and MULTIPLY by 3 (this applies to both 7 and 8 digits)
如果我理解正确,您需要以下解决方案:
eight_digitValid
或seven_digitCheck
是字符串。所以提取第一个数字,把它转换成int
,然后相乘相关问题 更多 >
编程相关推荐