[Tutor] Populating a list
Saad Javed
sbjaved at gmail.com
Mon Oct 22 03:44:51 CEST 2012
My program downloads multiple entry values from the net. I'm trying to
combine them in a list in a particular sequence.
l = []
feed1 = urllib2.urlopen(rssPage1)
tree1 = etree.parse(feed1)
x = tree1.xpath("/rss/channel/item/title/text()")
y = tree1.xpath("/rss/channel/item/pubDate/text()")
z = tree1.xpath("/rss/channel/item/link/text()")
for e, f, g in zip(x, y, z):
l.append([e, f, g])
print l
The problem I'm facing is that the values don't combine into a single list
("l"). It keeps printing multiple lists with three values e, f, g as the
xml tree is parsed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121022/62368dca/attachment.html>
More information about the Tutor
mailing list