how to append semicolon to a variable
Grant Edwards
grante at visi.com
Sat Aug 13 13:02:47 EDT 2005
On 2005-08-13, yaffa <yxxxxlxxxxx at gmail.com> wrote:
> i have the following lines of python code:
>
> couch = incident.findNextSibling('td')
> price = couch.findNextSibling('td')
> sdate = price.findNextSibling('td')
> city = sdate.findNextSibling('td')
> strUrl = addr.b.string
> currently what this ends up doing is creating something like this
>
> couch3201/01/2004newyork
>
> now what i want to do is add a semicolon after the couch, price, sdate,
> city so that i get something like this
>
> couch;32;01/01/2004;new york
Try this:
s = ';'.join([couch,price,sdate,city])
print s
> p.s. i tried couch = couch + ';'
> and then i tried couch = couch + ";"
both of those should have worked fine.
> and then i tried couch = couch.append ';'
1) The append() method of a sequence doesn't return anything.
2) You call methods using ()
3) String are immutable, and therefore don't have an append
method.
Perhaps you ought to read through the tutorial?
--
Grant Edwards grante Yow! LOOK!!! I'm WALKING
at in my SLEEP again!!
visi.com
More information about the Python-list
mailing list