[Tutor] Re: print out lines that start with a word
Wolfram Kraus
kraus at hagen-partner.de
Wed Feb 9 11:48:23 CET 2005
Liam Clarke wrote:
> print [w for w in j.split() if w[0] == '*' and w[-1] == '*']
>
>
> Wouldn't that only work if it was bug *car* jeff?
>
> I can imagine bug*car*jeff would throw it.
>
> Cheers,
>
> Liam Clarke
x = 'bug*car*jeff*foo*bar'
[x.split('*')[a] for a in range(1,len(x.split('*')), 2)]
When you mix * and spaces I will give up ;-)!
Wolfram
More information about the Tutor
mailing list