Count of a specific character in a word in Python 3 [duplicate]

6

I recently asked a similar question, but received answers where my entry was supposed to be a number. Can you count how many specific characters you have in a word? As in "example" it has "2 and".

    
asked by anonymous 16.12.2017 / 15:06

1 answer

5

Use str.count :

"exemplo".count("e")
=> 2
    
16.12.2017 / 15:21