spliting on ":"

Duncan Booth duncan.booth at invalid.invalid
Sat Mar 4 11:59:14 EST 2006


s99999999s2003 at yahoo.com wrote:

> print line.split(":")[-1]
> 
> but line 4 and 5 are not printed as there is no ":" to split. It should
> print a "blank" at least.
> how to print out lines 4 and 5 ?
> eg output is
> 
> yyy
> yyy
> yyy
> 
> 
> yyy

if ":" in line:
   print line.split(":")[-1]
else:
   print

what's the problem?



More information about the Python-list mailing list