Workout #12: Words with most repeated letters

Sep 25, 2021

Write a function, most_repeating_word, that takes a sequence of strings as input. The function should return the string that contains the greatest number of repeated letters. In other words

For each word, find the letter that appears the most times.

Find the word whose most-repeated letter appears more than any other.

That is, if words is set to

words = [‘this’, ‘is’, ‘an’, ‘elementary’, ‘test’, ‘example’] then your function should return elementary. That’s because

  • this has no repeating letters.
  • is has no repeating letters.
  • an has no repeating letters.
  • elementary has one repeating letter, e, which appears three times.
  • test has one repeating letter, t, which appears twice.
  • example has one repeating letter, e, which appears twice.

TRY IT YORUSELF

ANSWER

https://colab.research.google.com/drive/1YyKg7uvZX-srHiwDlda5HUsLdg6R5bW5?usp=sharing

--

--

Abish Pius
Abish Pius

Written by Abish Pius

Data Science Professional, Python Enthusiast, turned LLM Engineer

No responses yet