samedi 25 novembre 2017

Multiply each number / digit by increasing values

For each digit, it must multiply by 1 increasing to 9. Then add all together.

For example if the number in the file is 013149498, it should be:

(0*1) + (1*2) + (3*3) + (1*4) + (4*5) + (9*6) + (4*7) + (9*8) + (8*9)

Right now I have all numbers multiplying by 2.

isbn_file = open('isbns.txt', 'r')

for line in isbn_file:
    if size == 11:
            for number in range(0,9):
            maths = number * 2
            print(number, maths, sep="...")

Aucun commentaire:

Enregistrer un commentaire