Tuesday, 10 September 2013

python : why use %s instead of calling variables directly

python : why use %s instead of calling variables directly

I was just wondering why use %s instead of calling the variable directly ex:
playername = "george"
print "my name is %s" % playername
print "my name is", playername
calling the variable directly is a little shorter and they both print the
same results so is there something i have not learned about yet that will
come back to bite me if i forgo the use of the %?

No comments:

Post a Comment