Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

all the positions of a letter occurrences in a string python

s = 'Apples are totally awesome'

l = [idx for idx, item in enumerate(s.lower()) if 'a' in item]
print(l)
#output: [0, 7, 14, 19]
Comment

PREVIOUS NEXT
Code Example
Python :: replace nat with date pandas 
Python :: pytest run only failed test 
Python :: read a file and split the words python 
Python :: how to get something from a certian possition in a list python 
Python :: public in python 
Python :: split a given number in python 
Python :: python dataframe remove header 
Python :: how to delete a specific line in a file 
Python :: pandas df row count 
Python :: pandas count freq of each value 
Python :: selenium chromeoptions user agent 
Python :: python - row slice dataframe by number of rows 
Python :: python set negative infinity 
Python :: multirow np.rand.randint 
Python :: find order of characters python 
Python :: how to pick out separate columns from the pandas dataframe object 
Python :: how to add column to np array 
Python :: tkiner lable 
Python :: how to add element at first position in array python 
Python :: ternary operator python 
Python :: how to check if string is camelcase python 
Python :: how to check python version on terminal 
Python :: how to transpose a 2d list in python 
Python :: how to use print in python 
Python :: get string until character python 
Python :: pandas shift column down 
Python :: pandas read csv skip first line 
Python :: combine two dictionary adding values for common keys 
Python :: flatten a 2d list 
Python :: tkinter progressbar set value 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =