This is a follow up question to How to count characters in a string? and to Find out how many times a regex matches in a string in Python
I want to count all alphabet characters in the string:
'Go until jurong point, crazy.. Available only in bugis n great world la e buffet... Cine there got amore wat...'
The str.count()
method allows for counting a specific letter. How would one do that for counting any letter in the entire alphabet in a string, using the count method?
I am trying to use a regex inside the count method, but it returns 0 instead of 83. The code I am using is:
import re
spam_data['text'][0].count((r'[a-zA-Z]'))
When I use:
len(re.findall((r'[a-zA-Z]'), spam_data['text'][0]))
it returns a length of 83.
Why does count return a 0 here?