Thursday 15 July 2010

python - Getting the length of a string from a the first instance of a particular character -



python - Getting the length of a string from a the first instance of a particular character -

the title sums really. need find length of string in python first instance of particular character. help appreciated. give thanks you.

>>> s = 'this test string' >>> len(s[s.index('some_character'):])

where some_character character you're searching for.

len() documentation good reply list slicing

python

No comments:

Post a Comment