Count of a specific character in a word in Python 3

Asked

Viewed 4,113 times

6

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

1 answer

5


Use the str.count:

"exemplo".count("e")
=> 2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.