我刚刚修复了我的 ISBN 校验码代码以提高效率,但现在它又出现了属性错误:
AttributeError: 'int' object has no attribute 'append'
这是代码:
isbn = 0
result = 0
results = 0
print("Please input your ISBN 1 number at a time")
isbn = [int(input("ISBN character {0}: ".format(i)))
for i in range(1, 11)]
results.append(isbn[0] * 11)
results.append(isbn[1] * 10)
results.append(isbn[2] * 9)
results.append(isbn[3] * 8)
results.append(isbn[4] * 7)
results.append(isbn[5] * 6)
results.append(isbn[6] * 5)
results.append(isbn[7] * 4)
results.append(isbn[8] * 3)
results.append(isbn[9] * 2)
enter code here
results = sum(results)
result = results % 11
result = 11 - result
result = str(result)
if result == "10":
result = "X"
print("Your ISBN is '",
isbn[range(10)],result,"'")
print("The checksum is",result)
非常感谢