s=input() input_code=list(s.replace('-','')) code = input_code[-1] if code == 'X': code = 10 others = input_code[0:-1] k=1 sum_final=0 first="" second="" third="" last="" final_list=[] ans="" for i in others: sum_final += int(i)*k k+=1 correct_ISBN = sum_final%11 if correct_ISBN == int(code): print('Right') elif correct_ISBN == 10 and correct_ISBN != code: del input_code[-1] input_code.append('X') first = str(input_code[0]) second = str(input_code[1])+str(input_code[2])+str(input_code[3]) third = str(input_code[4])+str(input_code[5])+str(input_code[6])+str(input_code[7])+str(input_code[8]) last = str(input_code[-1]) final_list.append(first) final_list.append(second) final_list.append(third) final_list.append(last) ans = "-".join(str(e) for e in final_list) print(ans) else: del input_code[-1] input_code.append(str(correct_ISBN)) first = str(input_code[0]) second = str(input_code[1])+str(input_code[2])+str(input_code[3]) third = str(input_code[4])+str(input_code[5])+str(input_code[6])+str(input_code[7])+str(input_code[8]) last = str(input_code[-1]) final_list.append(first) final_list.append(second) final_list.append(third) final_list.append(last) ans = "-".join(str(e) for e in final_list) print(ans)
幫幫把程式變得更好吧!