how do I count spaces at the beginning of a string?

Norman Lorrain normanlorrain at telusplanet.net
Wed May 16 23:30:46 EDT 2007


On 2007-05-16 20:02:18 -0600, walterbyrd <walterbyrd at iname.com> said:

> The strings start with whitespace, and have a '*' or an alphanumeric
> character. I need to know how many whitespace characters exist at the
> beginning of the string.
a = '   three spaces'
print len(a) -len(a.lstrip())




More information about the Python-list mailing list