cds201/readability_is_king.py
2026-01-18 10:48:13 +01:00

24 lines
714 B
Python

# Readability is King Codewars Kata https://www.codewars.com/kata/52b2cf1386b31630870005d4
def avarage_words_sentence(text):
sentences = text.split(".")
sentences.pop(-1)
average_words_sentence = []
for sentence in sentences:
sentence = sentence.split()
average_words_sentence.append(len(sentence))
return sum(average_words_sentence) / len(average_words_sentence)
def avarage_syllables(text):
vowels = {"a", "e", "i", "o", "u"}
def flesch_kincaid(text):
average_words_sentence = avarage_words_sentence(text)
avaraage_syllables = avaraage_syllables(text)
return average_words_sentence
print(flesch_kincaid("To be or not to be. That is the question."))