On May 17, 8:18 am, Steven Howe <[EMAIL PROTECTED]> wrote:
> walterbyrd wrote:
> > I don't know exactly what the first non-space character is. I know the
> > first non-space character will be * or an alphanumeric character.
>
> using builtin function rindex
But only if there is a guarantee that are spaces nowhere else in the
string:
a = ' abc'
print a.rindex(' ') + 1
=> 4
Good, but ...
b = ' ab c'
b.rindex(' ') + 1
=> 7
Ouch!
The difference method suggested by Daniel Nogradi, seems the most
obvious way.
len(b) - len(b.lstrip())
=> 4
Asun
--
http://mail.python.org/mailman/listinfo/python-list