ISBN = [int(e) for e in input("input ISBN :")]
sum = 10*ISBN[0]+9*ISBN[1]+8*ISBN[2]+7*ISBN[3]+6*ISBN[4]+5*ISBN[5]+4*ISBN[6]+3*ISBN[7]+2*ISBN[8]
for i in range(0,10):
sum_check = sum + i
if sum_check % 11 ==0:
print("n10 =",i)
ISBN.append(i)
OUTPUT
n10 = 5
[0, 2, 0, 1, 3, 1, 4, 5, 2, 5]
but i want this output
020134525
To print any list in python without spaces, commas and brackets simply do
print(*list_name,sep='')
If you want to print the list AS IS, python will alway print it within brackets:
[0, 2, 0, 1, 3, 1, 4, 5, 2, 5]
If you want to get all the numbers together, it means you want to join
the numbers in the list.
What you want to do is join
the items in the list, like this:
result = ''.join(list)
The object result
will be the numbers as you wanted, as:
020134525
Try ''.join(ISBN)
Alternatively, instead of having ISBN
as a list, make it str
.
ISBN = ''
(your code)
ISBN+=i
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.