3
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

  • 5
    `''.join(ISBN)` – erip Jul 14 '20 at 18:01
  • print(*ISBN, sep=''). There are plenty of answer on this topic, see for example: https://stackoverflow.com/questions/5445970/how-to-properly-print-a-list – terence hill Jul 14 '20 at 18:04
  • Does this answer your question? [How to "properly" print a list?](https://stackoverflow.com/questions/5445970/how-to-properly-print-a-list) – AMC Jul 15 '20 at 02:19

4 Answers4

4

To print any list in python without spaces, commas and brackets simply do

print(*list_name,sep='')
0

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
Josef Ginerman
  • 1,460
  • 13
  • 24
0

if ISBN = [0, 2, 0, 1, 3, 1, 4, 5, 2, 5]

Then you can write

ISBN = [0, 2, 0, 1, 3, 1, 4, 5, 2, 5]
print(''.join(str(i) for i in ISBN))
-1

Try ''.join(ISBN) Alternatively, instead of having ISBN as a list, make it str.

ISBN = ''
(your code)
ISBN+=i
pjk
  • 547
  • 3
  • 14