How to write a recursive function that takes a list and return the same list without vowels?
<p>I am supposed to write a recursive function that takes a list of strings or a list of lists of strings and return the list without vowels, if found. Here is my attempt to solve it:</p>

<pre><code>def noVow(seq):
    keys = ['a','i','e','o','u','u']
    if not seq or not isinstance(seq, list) :
        return 
    else:
        if seq[0]  in keys:
            del seq[0]
            return (noVow(seq[0:]))
        else:
            return (noVow(seq[1:]))


li = ["b", "c", "d","a"]
print (noVow(li))
</code></pre>

<p>I am aware that the bug lies in my base case however I can't come up with the right base case. </p>

<p>Note that the recursive function has to be written in pure functional programming i.e. side effects are not allowed.</p>

<pre><code>def no_vowel(seq):
    if not isinstance(seq, list):
        raise ValueError('Expected list, got {}'.format(type(seq)))
    if not seq:
        return []
    head, *tail = seq
    if isinstance(head, list):
        return [[no_vowel(head)]] + no_vowel(tail)
    else:
        if head in 'aeiou':
            return no_vowel(tail)
        else:
            return [head] + novowel(tail)   
</code></pre>

<p>The cool unpacking of the list is a Python 3 feature, and is very similar to functional programmings pattern matching.         </p>

python recursion functional-programming