The title sums it up really. I need to find the length of a string in python from the first instance of a particular character. Any help would be really appreciated. Thank you.
Asked
Active
Viewed 52 times
3 Answers
2
>>> s = 'this is a test string'
>>> len(s[s.index('some_character'):])
Where some_character
is the character that you're searching for.
-
you forgot a closing parenthesis after the ' on your second line of code – deweyredman Nov 10 '14 at 23:45
0
You could do something like:
a = 'blahblahbalh'
b = a.find('b')
c = len(a[b:])

Uyghur Lives Matter
- 18,820
- 42
- 108
- 144

deweyredman
- 1,440
- 1
- 9
- 12