+ 1
making a program to analyze text. Take the text as the first input and a letter as the second input, and output the frequency
Are there any bugs in the program? x = input(" ") val= ('s') k = len(x) num= 0 for i in x: if i==val: num = num+1 y = int(num/k*100) print(int(y))
2 Answers
+ 2
x = input(" ")
val=input (" ")
k = len(x)
num= 0
for i in x:
if i==val:
num = num+1
y = int(num/k*100)
print(int(y))
I did small change in ur code's 2 line as now it will take the letter as Input by the user.
0
text = input()
letter = input()
s = text.count(letter)
n= len(text)
freq = (s/n*100)
print(int(freq))