Parsing lists

Seamus Venasse python at polaris.ca
Sun Jul 9 02:20:36 EDT 2000


I am creating a simple list of titles and urls.  I would like to parse this
list, but I keep receiving an error.  Here is a simplified version of my
code and error received:

>>> list = [ 'title1', 'url1', 'title2', 'url2', 'title3', 'url3' ]
>>> for title, url in list:
...     print title, url
...
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: unpack sequence of wrong size

Of course, if I change the code as follows, at least it prints everything in
the list:

>>> list = [ 'title1', 'url1', 'title2', 'url2', 'title3', 'url3' ]
>>> for title in list:
...     print title
...
title1
url1
title2
url2
title3
url3

What am I missing the first example?  Any assistance would be greatly
appreciated.

Seamus





More information about the Python-list mailing list