+ 3
Can someone help me out... I don't know how to solve this problem. Please.
You are making a program to analyze text. Take the text as the first input and a letter as the second input, and output the frequency of that letter in the text as a whole percentage (Python).
3 ответов
+ 1
Um, pseudo code should look something like this
def freq(text, char):
counter 0
#start iter
iterate through text per character
if text[i] == char then counter+= 1
#end iter
p = counter/text.length
return (p*100)
+ 1
loop over the text , compare each character in text to the letter and increment a variable by 1 .
now print the percentage as variable/len(text) *100.
Show your attempt for further help .
0
text = input()
letter = input()
s = text.count(letter)
n= len(text)
freq = (s/n*100)
print(int(freq))