[Tutor] Re: print out lines that start with a word
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 == '*' and w[-1] == '*']
> Wouldn't that only work if it was bug *car* jeff?
> I can imagine bug*car*jeff would throw it.
> 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 ;-)!
More information about the Tutor