0

How to return the number of times a character repeats in a text fils

Counting number of times a character is in a text file https://code.sololearn.com/cqe2z4HpkxW1/?ref=app

21st Jun 2019, 5:05 PM
David Nierman
David Nierman - avatar
2 odpowiedzi
- 1
def CheckChar(text): c = 0 for x in AlphaNumericList: c += text.count(x); print(x, c);c = 0
21st Jun 2019, 7:28 PM
Choe
Choe - avatar
+ 3
You can use the count() method on a string. "dabidda".count("a") #returns 2
21st Jun 2019, 5:19 PM
Russ
Russ - avatar