How can I get this Python function to return a string instead of a list containing one string?
<p>How can I get this Python function to return a string instead of a list containing one string?</p>

<pre><code>def num_vowels(s):
    """ returns the number of vowels in the string s
        input: s is a string of 0 or more lowercase letters
    """
    if s == '':
        return 0
    else:
        num_in_rest = num_vowels(s[1:])
        if s[0] in 'aeiou':
            return 1 + num_in_rest
        else:
            return 0 + num_in_rest

#most vowels returns a list not a string
def most_vowels(wordlist):
    '''Takes a list of strings called wordlist and returns the string in
       the list with the most vowels.'''
    list_of_num_vowels = [num_vowels(x) for x in wordlist]
    max_val =  max(list_of_num_vowels)
    return [x for x in wordlist if num_vowels(x) == max_val] 
</code></pre>

<p>Some test cases:</p>

<pre><code>most_vowels(['vowels', 'are', 'amazing', 'things'])
</code></pre>

<p>output: <code>'amazing'</code></p>

<pre><code>most_vowels(['obama', 'bush', 'clinton'])
</code></pre>

<p>output: <code>'obama'</code></p>

<p>Thanks!</p>

<p>Your <code>most_vowels</code> function sort of reinvents the wheel. Python already given you a much simpler facility for this this - using <a href="https://docs.python.org/2/library/functions.html#max" rel="nofollow"><code>max</code></a> with an optional <code>key</code> argument, and just picking the word with the most vowels outright:</p>

<pre><code>def most_vowels(wordlist):
    return max(wordlist, key=num_vowels)
</code></pre>

python string