I don’t see problem in here, but Python thinks different:
x = 3
y = 7
z = 2
print "I told to the Python, that the first variable is %d!" % x
print "Anyway, 2nd and 3rd variables sum is %d. :)" % y + z
I get TypeError: cannot concatenate 'str' and 'int' objects.
Why is that so? I haven’t setted any variable as string… as much as I see.
%has a higher precedence than+, sos % y + zis parsed as(s % y) + z.If
sis a string, thens % xis a string, and(s % y) + zattempts to add a string (the result ofs % y) and an integer (the value ofz).