+ 6
How to count the frequency of a letter in a word in python??
13 Réponses
+ 6
word = 'mississippi'
for letter in set(word):
print(letter, '=', word.count(letter))
+ 12
s=input()
for i in range(len(s)):
if s[i] not in s[:i]:
print(s[i]+"="+s.count(s[i]))
+ 7
word = 'googlegooglehalohalo'
print(",".join(set(list(map((lambda x:x+"="+str(word.count(x))),word)))))
+ 4
Mateusz R
It won't work.
Try replacing variable 'str' to 'txt' or else.
It will work.
+ 4
def count(word):
result = dict()
for line in word:
local = word.count(line)
result[line] = local
return result
print(count("google"))
+ 4
Why r u going for some tough solutions?
Wanna Make it easy see here!!1
Letter Frequency Problem --
text=input()
letter=input()
count=0
for i in range(0,len(text)):
if letter==text[i]:
count+=1
fre=int((count/len(text))*100)
print(fre)
+ 2
I extended my code with the functionality you want. Take a look Siddhi.
+ 1
str = "SoloLearn"
freq = {}
for i in str:
if i in freq:
freq[i] += 1
else:
freq[i] = 1
print ("Frequency :\n "
+ str(freq))
+ 1
This is one of possible solutions:
https://code.sololearn.com/cz2fEt6X87D9/#py
+ 1
'mississippi'.count('i')
+ 1
I want the output like
Input string :google
Output:
g =2
o=2
l=1
e=1
0
In c I use the array method to find the frequency...
But in python array is not native you can use the numpy library for that ... Hope it will help
0
Here my code.
I tried to do in a beginner way ( very straightforward )
a=input()
b=input()
c=len(a)
cont = a.count(b)
volte = int((cont/c)*100)
print(volte)