0
a=str(input()) b=str(input('letter_')) c=len(a) d=a.count(b) e=d/c f=e*100 print(int(f))
Is it a correct code for frequency of a letter in a word
5 Answers
0
def char_frequency(word):
dict = {}
for n in word:
keys = dict.keys()
if n in keys:
dict[n] += 1
else:
dict[n] = 1
return dict
You can use this for character frequency
+ 3
abiram sakthivel ,
do you need to know just how often a certain letter appears in a string, or do you need to know the frequency of all letters that occur in the string?
+ 1
Hi abiram!
Of course, your code is correct.
But problem is that you have to print the exact output what is expected by Sololearn. Your code has a input prompt message. It's main reason that you're unable to pass in this practice. You can just remove the prompt message and check it again.
Here it is my solution for this practice.
text = input()
l = input()
print(int(text.count(l)/len(text)*100))
0
Brain & Bones ur code has been failed in sololearn but in pudroid it is crt