[Tutor] role playing game - help needed

ALAN GAULD alan.gauld at btinternet.com
Sat Dec 11 00:21:22 CET 2010

Thanks again Alan.  Much clearer now.  One final part I don't understand.
>>>> "%d is the result of %d + %d" % (6+7,6,7)
>I understand (I think) the 6+7 part but why the ,6,7 after that.  I could 
>see how either '6+7' or '6,7' would be the correct format but not both.

The format string has 3 percent markers - all numbers.
It is therefore expecting 3 values, so I have to give it them.
The first marker gets 6+7, ie 13. The second gets 6 
the third 7...

Look at the first example in the loops topic in my tutorial.
It uses variables in the same way rather than literal values, 
that might make it more obvious. Maybe :-)

Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101210/a7647551/attachment.html>

More information about the Tutor mailing list