ISBN 校验位求解器,用户反馈 [英] ISBN check digit solver, user feedback

查看:34
本文介绍了ISBN 校验位求解器,用户反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 ISBN 程序来解决校验位问题,我想这样做,当程序为您找到校验位时,它会打开一个新字符串,上面写着您是否愿意关闭程序",其中我已经这样做了.

I am making an ISBN program to solve the check digit and I want to make it so that when the program finds the check digit for you it opens a new string saying "would you like to close the program or not", which I have already done so.

如果他们的人说n"不,它会返回到开头,如果这个人说y",程序关闭,我被卡住并开始在互联网上搜索我的代码在下面,任何人都可以帮助调整它,谢谢.

If they person says 'n' for no it returns back to the beginning and if the person says 'y' the program closes I got stuck and started to search the internet my code is below could anyone help adjust it thanks you.

这是我的代码:

ISBN=input("Please enter a 10 digit number for the ISBN check digit:  ")

while len(ISBN)!= 10:

    print("Please try again and make sure you entered 10 digits.")
    ISBN=int(input("Please enter the 10 digit number again: "))
    continue

else:
    D1 =int(ISBN[0])*11

    D2 =int(ISBN[1])*10
    D3 =int(ISBN[2])*9
    D4 =int(ISBN[3])*8
    D5 =int(ISBN[4])*7
    D6 =int(ISBN[5])*6
    D7 =int(ISBN[6])*5
    D8 =int(ISBN[7])*4
    D9 =int(ISBN[8])*3
    D10=int(ISBN[9])*2
    Sum=(D1+D2+D3+D4+D5+D6+D7+D8+D9+D10)
    Mod=Sum%11
    D11=11-Mod
    if D11==10:
        D11='X'
    ISBNNumber=str(ISBN)+str(D11)
    print("Your 11 digit ISBN Number is *" + ISBNNumber + "*")

def close():
    close=input ("would you like to close the program or try again 'y' for Yes and 'n' for No:")

    while len(close)==1:
        if input == "n":s
            return (ISBN)
        elif input == "y":
            exit()
close()#

推荐答案

这会在您的代码中添加一个 for 循环

This adds a for loop in to your code

其他:

Sum = 0
for i in range(len(isbn)):
    sum= int(isbn[i])
mod=sum%11
digit11=11-mod
if digit11==10:
   digit11='X'
iSBNNumber=str(isbn)+str(digit11)
print('Your 11 digit ISBN Number is ' + iSBNNumber)

这篇关于ISBN 校验位求解器,用户反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆