[Tutor] newbie question
Alan Gauld
alan.gauld at btinternet.com
Mon Oct 15 18:56:09 CEST 2007
"Ramkumar Kashyap" <ramkumar.kashyap at gmail.com> wrote
> print "%s %s %s" % menu_specials["breakfast"],
> menu_specials["lunch"],
> menu_specials["dinner"]
Whoops, I also should have added parentheses around the values.
Otherwise Python sees a tuple consisting of the string and first
value followed by the two succeeding values. And the single value
doesn't match the 3 %s tokens.
So it should be:
>>> print "%s %s %s" % (menu_specials["breakfast"],
>>> menu_specials["lunch"],
menu_specials["dinner"])
Because of the parens you don't need the \ character so you can ignore
that bit.
Note to self: Test before posting!
Blush,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list