0 комментариев

Добрый день!

Мне бы хотелось, чтобы программа из списка cwords добавляла слова в список only, при том условии, что слова в списке only не будут повторяться. В коде, программа добавила только первое слово и остановилась. Как это можно исправить?

mammoth = »’
We have seen the Queen of cheese,
Laying quietly at your ease,
Gently fanned by evening breeze —
Thy fair form no flies dare seize.
All gaily dressed soon you’ll go
To the great Provincial Show,
To be admired by many a beau
In the city of Toronto.
Cows numerous as a swarm of bees —
Or as the leaves upon the trees —
It did require to make thee please,
And stand unrivalled Queen of Cheese.
May you not receive a scar as
We have heard that Mr. Harris
Intends to send you off as far as
The great World’s show at Paris.
Of the youth — beware of these —
For some of them might rudely squeeze
And bite your cheek; then songs or glees
We could not sing o’ Queen of Cheese.
We’rt thou suspended from baloon,
You’d caste a shade, even at noon;
Folks would think it was the moon
About to fall and crush them soon.
import re
cwords = re.findall(r’\b\w*[aeyuio]{3}\w*\b’, mammoth)
for word in cwords:
only = []
if word not in only:

Добавить комментарий