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".
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".
5
Use the str.count
:
"exemplo".count("e")
=> 2
Browser other questions tagged python python-3.x
You are not signed in. Login or sign up in order to post.
What specifics? Count all occurrences of 2 or of and or of any character?
– Guilherme Nascimento
The question is not duplicate, I see. There were to count the equal characters at the end of the input
– vinibrsl
From what I understand, none of the answers to the other question satisfy the question.
– Pablo Almeida
Yes, the other question uses mathematical methods, and not for words, I was kind of confused that they marked this as duplicate
– Darius da costa
duplicate of Python 3 make the program find out how much of a given digit is in a string or a number
– NoobSaibot