Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find charechtar index in string python

myString = 'Position of a character'
myString.find('s')
# 2
myString.find('x')
# -1
Comment

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])
Comment

PREVIOUS NEXT
Code Example
Python :: nice python turtle code 
Python :: memory usage in python 
Python :: input python 3 
Python :: python beginner projects 
Python :: python tkinter listbox detect selection change 
Python :: how to convert csv into list 
Python :: flask print request headers 
Python :: read .mat file in python 
Python :: cv2.flip 
Python :: unsigned int python 
Python :: python int to bytes 
Python :: python compiler to exe 
Python :: flask blueprint 
Python :: list methods append in python 
Python :: python .nlargest 
Python :: how to check a string is palindrome or not in python 
Python :: python convert input into lowercase 
Python :: file methods in python 
Python :: opencv namedwindow 
Python :: how to find permutation of numbers in python 
Python :: dot operator in python 
Python :: filter dict by list of keys python 
Python :: laplace transform python 
Python :: pandas sort dataframe by index 
Python :: django queryset count 
Python :: How to check palindrom in python 
Python :: check auth user django 
Python :: to str python 
Python :: openai gym random action 
Python :: Tensor.expand_as 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =