[Tutor] newbie question

Ramkumar Kashyap ramkumar.kashyap at gmail.com
Mon Oct 15 17:01:31 CEST 2007

Hi all,

I have just started learning to program and am working through the Beginning
Python from Wrox.

I am working through one of the examples in the books on dictionaries. Here
is the example.

>>> menu_specials = {"breakfast" : "sausage and eggs",
... "lunch" : "split pea soup and garlic bread",
... "dinner": "2 hot dogs and onion rings"}
>>> print "%s" % menu_specials["breakfast"]
sausage and eggs
>>> print "%s" % menu_specials["lunch"]
split pea soup and garlic bread
>>> print "%s" % menu_specials["dinner"]
2 hot dogs and onion rings

I am trying to print out the entire dictionary but am getting an error.
print "%s %s %s" % menu_specials["breakfast", "lunch", "dinner"]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
KeyError: ('breakfast', 'lunch', 'dinner')

I also tried
print "%s %s %s" % menu_specials["breakfast"], menu_specials["lunch"],
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: not enough arguments for format string

What is the correct syntax to output breakfast, lunch and dinner with one


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071015/1740d632/attachment.htm 

More information about the Tutor mailing list