-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,583
  • 8
  • 39
  • 41
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
0

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

Inbl
  • 630
  • 2
  • 5
  • 18