Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

program count the number of occurrences of a letter in a string python

# count the occurence of element in the string
l=input("enter the string")
d={}
print(l)
for i in l:
 if i not in d:
  d[i]=l.count(i)
 else:
  pass
print("Frequency of each element-")

for k in d:
  print(k,"-",d[k])
output:
'''
enter the string14587324569248
14587324569248
Frequency of each element-
1 - 1
4 - 3
5 - 2
8 - 2
7 - 1
3 - 1
2 - 2
6 - 1
9 - 1
'''
Comment

string count substring occurences pytohn

string.count(substring, [start_index], [end_index])
Comment

PREVIOUS NEXT
Code Example
Python :: how to write the character from its ascii value in python 
Python :: pandas two dataframes equal 
Python :: python beautiful 
Python :: how to get key of a particular value in dictionary python using index 
Python :: pygame window at center 
Python :: ssl django nginx 
Python :: count list python 
Python :: python parallel processing for loop 
Python :: convert all images in folder to jpg python 
Python :: string to bits python 
Python :: pandas series index of value 
Python :: difference between two dictionaries python 
Python :: version python 
Python :: pygame zero how to draw text 
Python :: how to iterate over columns of pandas dataframe 
Python :: python mixins 
Python :: box plot seaborn python 
Python :: add column to existing numpy array 
Python :: pdf to csv 
Python :: python convert multidimensional array to one dimensional 
Python :: abc python 
Python :: what does int do in python 
Python :: python datetime offset 
Python :: python map string to int 
Python :: twitter api v2 python tweepy 
Python :: extract integer from a string in pandas 
Python :: or in django query 
Python :: try python import 
Python :: pandas select first within groupby 
Python :: how to make a column a factor in pandas 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =