We will use the Flesch–Kincaid Grade Level to evaluate the readability of a piece of text. This grade level is an approximation for what schoolchildren are able to understand a piece of text. For example, a piece of text with a grade level of 7 can be read by seventh-graders and beyond.

The way to calculate the grade level is as follows:

    (0.39 * average number of words per sentence) + (11.8 * average number of syllables per word) - 15.59

Write a function that will calculate the Flesch–Kincaid grade level for any given string. Return the grade level rounded to two decimal points.

Ignore hyphens, dashes, apostrophes, parentheses, ellipses and abbreviations.

Remember that the text can contain more than one sentence: code accordingly!

**HINT**: Count the number of vowels as an approximation for the number of syllables, but count groups of vowels as one (e.g. `deal` is one syllable). **Do not** count `y` as a vowel!

## Example

```python
"The turtle is leaving." ==> 3.67
```

The average number of words per sentence is `4` and the average number of syllables per word is `1.5`. The score is then `(0.39 * 4) +  (11.8 * 1.5) - 15.59` = `3.67`

Difficulty: introductory

Starter code:

def flesch_kincaid(text):
	

Solutions:
from re import compile as reCompile

SENTENCE = reCompile(r'[.!?]')
SYLLABLE = reCompile(r'(?i)[aeiou]+')

def count(string, pattern):
    return len(pattern.findall(string))

def flesch_kincaid(text):
    nWords = text.count(' ') + 1
    return round(0.39 * nWords / count(text, SENTENCE) + 11.8 * count(text, SYLLABLE) / nWords - 15.59, 2)

import re

def flesch_kincaid(text):
    
    _words = lambda s: [''.join(c for c in w if c.isalpha) for w in s.split()]
    
    _syllables = lambda ws: sum(max(len(re.findall('[aeiou]+', w)), 1) for w in ws)
    
    sentences = [_words(s) for s in re.split(r'[.!?]+', text.lower()) if s]
    p1 = 0.39 / len(sentences) * sum(len(w) for w in sentences) 
    p2 = 11.8 / sum(len(w) for w in sentences) * sum(_syllables(s) for s in sentences) 
    return round(p1 + p2 - 15.59, 2)


import re
def flesch_kincaid(text):
    nLines = len(re.findall(r'([.?!;:]+)',text))
    nWords = text.count(' ')+1
    nSyll = len(re.findall(r'([aeiou]+)',text, flags=re.IGNORECASE))
    return round( 0.39 * nWords/nLines + 11.8 * nSyll/nWords - 15.59, 2)

from re import findall
flesch_kincaid=lambda text: round(len(text.split(" "))*0.39/len(findall("[.!?]",text))+len(findall("[AEIOUaeiou]+",text))*11.8/len(text.split(" "))-15.59,2)

V = 'aeouiAEOUI'

def flesch_kincaid(text):
    sentences = text.count(".") + text.count("!") + text.count("?")
    words     = text.count(" ") + 1
    syllables = sum(p not in V and c in V for p, c in zip(" " + text, text))
    return round(0.39 * words / sentences + 11.8 * syllables / words - 15.59, 2)

import re
def flesch_kincaid(s):
    w = len(s.split())
    return round(0.39*w/len(re.split(r'[!.?]',s)[:-1])+11.8*len(re.findall(r'[aeiou]+',s,re.I))/w-15.59,2)

import re

def flesch_kincaid(text):
    words = len(text.split())
    syllables = len(re.findall('[aeiou]+', text.lower()))
    sentences = len(re.split('[.!?]+', text.strip('.!?')))
    
    return round(0.39 * words / sentences + 11.8 * syllables / words - 15.59, 2)

import re

def flesch_kincaid(text):
    sen_l = re.split('[.!?]', text)
    words, syllables, sentences = 0, 0, len(sen_l)-1
    for sen in sen_l[:-1]:
        for w in sen.split():
            words += 1
            syllables += len(re.findall(r'[aeiouAEIOU]+',w))
    return round(0.39*words/sentences+11.8*syllables/words-15.59, 2)


import re

def flesch_kincaid(text):
    words = len(re.findall("\w+", text))
    syl = len(re.findall("[aeiou]+", text, re.I))
    sen = len(re.findall("[\w\s]+", text))    
    res = (0.39 * words/sen) + (11.8 * syl / words) - 15.59
    return round(res * 100) / 100.0


import re
 
def syl_count(word):
    return len(re.findall(r'[aeiou]+', word.lower()))

def flesch_kincaid(text):
    sentences_cnt = len([x for x in re.sub('\.|!|\?', '.', text).split('.') if x != ''])
    words_cnt = float(text.count(' ') + 1);
    syl_cnt = 0.0;
    for word in text.split(' '):
        syl_cnt += syl_count(word);
    syl_cnt /= words_cnt
    return round((0.39 * words_cnt / sentences_cnt) + (11.8 * syl_cnt) - 15.59, 2)