# Align iterable : error “string cannot switch from manual field specification to automatic field numbering” [duplicate]

So here is my code :

``````def f(n):
if n == 0:
return 1
else:
result = 1
for i in range(1,n+1):
result = result * i
return result
def a(n):
sum = 0
z = 0
for i in range(n+1):
sum += f(i)
print('{0:<4}! = {1:<4}  no.multi. ={} sum of {}!  = {}   no.multi. = {}'.format(i,f(i),i,i,sum,z))
z = z + (i+1)
a(19)
``````

I need to get this output:

But instead i get a sort of pyramid like

I tried to format inside the brackets but i always get the error : "cannot switch from manual field specification to automatic field numbering" Thank you in advance

I declared variable `strong_i` which is string of `i` with `!`, to take into account `!` when choosing amount of spaces when printing `i` with `!`.

``````def f(n):
if n == 0:
return 1
else:
result = 1
for i in range(1,n+1):
result = result * i
return result
def a(n):
sum = 0
z = 0
for i in range(n+1):
sum += f(i)
strong_i = str(i) + '!'
print('{0:<4}= {1:<20}  no.multi. = {2:<2} sum of {3:<3}  = {4:<20}   no.multi. = {5}'.format(strong_i,f(i),i,strong_i,sum,z))
z = z + (i+1)
a(19)
``````

Output:

``````0!  = 1                     no.multi. = 0  sum of 0!   = 1                      no.multi. = 0
1!  = 1                     no.multi. = 1  sum of 1!   = 2                      no.multi. = 1
2!  = 2                     no.multi. = 2  sum of 2!   = 4                      no.multi. = 3
3!  = 6                     no.multi. = 3  sum of 3!   = 10                     no.multi. = 6
4!  = 24                    no.multi. = 4  sum of 4!   = 34                     no.multi. = 10
5!  = 120                   no.multi. = 5  sum of 5!   = 154                    no.multi. = 15
6!  = 720                   no.multi. = 6  sum of 6!   = 874                    no.multi. = 21
7!  = 5040                  no.multi. = 7  sum of 7!   = 5914                   no.multi. = 28
8!  = 40320                 no.multi. = 8  sum of 8!   = 46234                  no.multi. = 36
9!  = 362880                no.multi. = 9  sum of 9!   = 409114                 no.multi. = 45
10! = 3628800               no.multi. = 10 sum of 10!  = 4037914                no.multi. = 55
11! = 39916800              no.multi. = 11 sum of 11!  = 43954714               no.multi. = 66
12! = 479001600             no.multi. = 12 sum of 12!  = 522956314              no.multi. = 78
13! = 6227020800            no.multi. = 13 sum of 13!  = 6749977114             no.multi. = 91
14! = 87178291200           no.multi. = 14 sum of 14!  = 93928268314            no.multi. = 105
15! = 1307674368000         no.multi. = 15 sum of 15!  = 1401602636314          no.multi. = 120
16! = 20922789888000        no.multi. = 16 sum of 16!  = 22324392524314         no.multi. = 136
17! = 355687428096000       no.multi. = 17 sum of 17!  = 378011820620314        no.multi. = 153
18! = 6402373705728000      no.multi. = 18 sum of 18!  = 6780385526348314       no.multi. = 171
19! = 121645100408832000    no.multi. = 19 sum of 19!  = 128425485935180314     no.multi. = 190
``````