How do I do this without string.count(), because it is listed as deprecated in Python v2.7.3 documentation?
string.count()
I am unable to find what I should use instea
Without using count you can do this:
def my_count(my_string, key_char): return sum(c == key_char for c in my_string)
Result:
>>> my_count('acavddgaaa','a') 5