0

Trying to solve how many letter

Only one test case comes out right text =str(input()) letter =str(input()) keg=letter.count(text) print(keg)

7th Apr 2021, 11:51 AM
Simisola Osinowo
Simisola Osinowo - avatar
10 Respuestas
+ 5
Write a function that takes a string and a letter as its arguments and returns the count of the letter in the string. Sample Input hello, how are you? o Sample Output 3 Explanation: The letter o appears 3 times in the given text.
7th Apr 2021, 11:52 AM
Simisola Osinowo
Simisola Osinowo - avatar
+ 3
Looking at the example, <text> was "hello, how are you?", and <letter> was "o". I think you are supposed to count frequency of <letter> inside <text>, and not the other way around. So you need this instead keg = text.count( letter )
7th Apr 2021, 12:50 PM
Ipang
+ 3
text = input() letter = input() def letter_count(text, letter): x=text.count(letter) return x print(letter_count(text, letter))
20th Feb 2022, 4:52 PM
Yassmine Attar
Yassmine Attar - avatar
+ 1
Ipang sorry it worked Thanks
8th Apr 2021, 11:26 AM
Simisola Osinowo
Simisola Osinowo - avatar
+ 1
t=input() l=input() def lc(t,l): c=t.count(l) print(c) lc(t,l) 👍
25th Apr 2021, 9:33 AM
Walnut
+ 1
text = str(input()) letter = str(input()) def letter_count(): print(text.count(letter)) letter_count()
16th May 2022, 8:55 AM
Junior Jackson
Junior Jackson - avatar
0
Ipang it did not work ,it gave no output
7th Apr 2021, 9:25 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
Show me updated code bro
8th Apr 2021, 3:49 AM
Ipang
0
Ok good job! 👍
8th Apr 2021, 11:28 AM
Ipang
0
def letter_count(text, letter): x=text.count(letter) return x text = input() letter = input() print(letter_count(text, letter))
30th Mar 2023, 1:20 PM
Vitor Lucas Mesquita Borges
Vitor Lucas Mesquita Borges - avatar