-1

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.

xxkatiexx
  • 1
  • 1

3 Answers3

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

Where some_character is the character that you're searching for.

len() documentation
Good answer for list slicing

Community
  • 1
  • 1
Celeo
  • 5,345
  • 8
  • 38
  • 40
0

You could do something like:

a = 'blahblahbalh'
b = a.find('b')
c = len(a[b:])
Uyghur Lives Matter
  • 17,261
  • 40
  • 105
  • 135
deweyredman
  • 1,430
  • 1
  • 9
  • 12
0

len(myStr[myStr.find('insert character here'):])

Inbl
  • 610
  • 1
  • 5
  • 17