Reputation: 1143
I was just trying to print the values of variables in a Label
declaration as given below
c = Label(root, text="Enter The Number Of Fruits In Basket%d Of Type%d\n"%j,i)
but I am getting the below error
SyntaxError: non-keyword arg after keyword arg
Am I missing anything, or declaring any arg wrongly?
Upvotes: 0
Views: 195
Reputation: 15987
Because you haven't used brackets around j, i
for the format string, Python thinks that i
is a variable being passed to the Label()
function as the 3 argument, instead of the format string. And since you've put text=
(as a named argument) already, then all subsequent args also have to be named.
Add the brackets around j, i
and then it should be okay:
c = Label(root, text="Enter The Number Of Fruits In Basket%d Of Type%d\n" % (j, i))
Upvotes: 1