making a program to analyze text. Take the text as the first input and a letter as the second input, and output the frequency | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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))

7th Apr 2021, 7:16 AM
Khushboo Golampalle
Khushboo Golampalle - avatar
2 Antworten
+ 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.
7th Apr 2021, 7:22 AM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
0
text = input() letter = input() s = text.count(letter) n= len(text) freq = (s/n*100) print(int(freq))
8th Jul 2022, 12:29 PM
PAULINE ONYEUKWU