On Thu, Jul 30, 2009 at 3:19 PM, Marv Boyes<[email protected]> wrote: > Hello, all. This is probably embarrassingly basic, but I haven't been able > to find something that works. > > I'm working on a script that needs to manipulate a list (not 'list' in the > Python sense) of URLs returned in a server response. Right now, I'm > stripping the XML tags from that response and assigning the resulting list > of URLs to a variable so I can print it in the terminal. So when I do, say, > 'print urls' I get something like this: > > http://server.com/thing1 > http://server.com/thing2 > http://server.com/thing3 > > And so on. What I would _like_ to do is assign each line of that list to a > separate variable, so that I can format my output to be more explicit; > something like this: > > Link to Thing1: http://server.com/thing1 > Link to Thing2: http://server.com/thing2
It looks like your "list" of URLs is a string containing one URL per line. If you put it in an actual list, you can process it more flexibly. Something like urlList = urls.splitlines() for i, url in enumerate(urlList): print "Link to Thing%s: %s" % (i, url) Kent _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
