TypeError: not enough arguments for format string

solve python

for i in range(1,10):

​    for j in range(1,i+1):

​        s = i*j

​        print('%d*%d='%i,j,s,end="\t") 

​    print("\t")

Type error: not enough arguments for format string

Once the parameters are enclosed in brackets (as shown below), the problem is solved

        print('%d*%d='%(i,j),s,end="\t") 

Summary

When there are multiple formatted outputs, the parameters after% should be enclosed in brackets

​ print(“%s : %s “%(x,y))

Similar Posts: