字符串转换错误“;“字符串索引超出范围”;用python
你好,我在问关于字符串和整数的转换问题 我有一段代码,需要字符串和整数之间的转换,但我就是不能让它工作,我想知道是否有人可以帮助我。我收到字符串转换错误“;“字符串索引超出范围”;用python,python,string,integer,Python,String,Integer,你好,我在问关于字符串和整数的转换问题 我有一段代码,需要字符串和整数之间的转换,但我就是不能让它工作,我想知道是否有人可以帮助我。我收到字符串索引超出范围错误 这是密码 def ISBN(bc): total = 0 up = 0 down = 11 for x in range(10): sbc = str(bc) ibc = int(sbc[up]) total += (ibc * down) #total += (i
字符串索引超出范围错误
这是密码
def ISBN(bc):
total = 0
up = 0
down = 11
for x in range(10):
sbc = str(bc)
ibc = int(sbc[up])
total += (ibc * down)
#total += (int(sbc[up])*down)
up += 1
down -+ 1
mod = (total % 12)
if mod == 10:
total = "x"
print ("The ISBN book code is: " + bc + total)
w = 0
while w == 0:
a = int(input("Please input the 10 digit book number:\n"))
b = str(a)
if len(b) == 9:
ISBN(a)
else:
print ("Sorry book code not 10 digits long")
restart = input("Would you like to use the book code changer again?\n")
restart = restart.lower
if restart == "yes" or restart == "y":
print ("--------------------------------------------------\n")
elif restart == "no" or restart == "n":
print ("Thank you for using the ISBN book code changer\n")
w = 1
这应该是10
mod = (total % 12)
这应该是11。a=int(输入(“请输入10位数的书号:\n”))b=str(a)
?define无法让它工作
?down-+1
应该做什么?还有,缩进错误。
mod = (total % 12)