On the print line it is showing syntax error...why?

Viewed 30
def tka(A):
    
    arr=[100,50,20,10,5,2,1]
    i=0
    for i in range(len(arr)):
        n=A//arr[i]
        p=A%arr[i]
        print(%n "nota (s) de R$ %d" %arr[i]",00" )
        A=p

A=int(input())
tk=tka(A)
2 Answers

Try changing :

print(%n "nota (s) de R$ %d" %arr[i]",00" )

to

print(f"{n} nota (s) de R$ {arr[i]},00")

I think you wanted Python string interpolation with the percent (%) operator.

def tka(A):
    
    arr=[100,50,20,10,5,2,1]
    i=0
    for i in range(len(arr)):
        n=A//arr[i]
        p=A%arr[i]
        print("%d nota (s) de R$ %d" % (n, arr[i]) , ",00" )
        A=p

A=int(input())
tk=tka(A)
Related