Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to get all index of a char of a string in python

word = 'Hello'
to_find = 'l'

# in one line
print([i for i, x in enumerate(word) if x == to_find])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #index #char #string #python
ADD COMMENT
Topic
Name
5+7 =