# How to find words that have the number of voices equal to the number of consents and their serial numbers

• Dana's next line:

So she was considering in her own mind, as well as she could, for the hot day made her feel very sleepy and stupid, whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.

How do you find words that have the number of written letters equal to the number of agreed?
How do you find the serial numbers?

The design should be initialized in the programme code.

• In principle, it is not important in which language of programming the task should be pursued. It's important to understand the algorithm.
The author &apos; s challenge is:

• Compile the list of capital letters
• Compile a list of agreed letters
• Break the line on the list of words.
• Find the number of intersecting elements among the letters in the word and list of the public
• Find the number of overlapping elements among the letters in the word and list of agreed
• Compare the number of verbal and

According to the https://simple.wikipedia.org/wiki/Vowel It is important to remember the following:

The Y-bag could be like a "cry," "sky, "fly" or "why"
I'd say "yellow, "yacht," "yam" or "yesterday."

Implementation for the option when `Y` public:

``````# coding=utf-8
import re
s = 'So she was considering in her own mind, as well as she could,'
+ ' for the hot day made her feel very sleepy and stupid, whether the pleasure'
+ ' of making a daisy-chain would be worth the trouble of getting up'
+ ' and picking the daisies, when suddenly a White Rabbit with pink eyes'
+ ' ran close by her.'
Определяем списки согласных и гласных букв
vowels = list("aeiouyAEIOUY")
consonants = list("bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ")
С помощью регулярного выражения разбиваем строку на слова
words = re.findall(r'([a-zA-Z]+(?:['-][a-zA-Z]+)*)', s)
enumerate нужен для получения индекса слова в строке
for index, word in enumerate(words):
# Считаем количество гласных/согласных букв в слове
number_of_vowels = sum(x in vowels for x in word)
number_of_consonants = sum(x in consonants for x in word)
# Если количество согласных и гласных букв равно,
# то выводим порядковый номер текущего слова.
# Помним, что индекс начинается с 0, а порядковые номера с 1. Нивелируем эту разницу.
if number_of_vowels == number_of_consonants:
print(index + 1, word)
``````

In writing this response, I used this response to SO:
https://stackoverflow.com/a/4775018/2486051

## Update

Corrections:

• A mistake was made, which made it incorrect to process words with repetitive letters
• Delete the method .lower(s)
• Translation between sound and letter in response
• The erroneous statement about the mere algorithm of implementation was deleted
• A further observation was made that a decision was not universal in all cases.

Limitations:

• In this implementation, a set of letters [a-zA-Z] between which defis or single-size can be used shall be considered.
• The abbreviations and words written by the transcrime are not analysed in this exercise.

Thank you very much to the user. https://ru.stackoverflow.com/users/23044/jfs for a specific comment that he correctly made mistakes and misstatements in my answer.

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2