Q:

Recursive function to remove vowels

I'm trying to write a recursive program that returns a string of letters from a word that are non vowels. My code right now print's out all of the non vowels of "University" but never ends . Any ideas?
def removeVowels9(aString):
    if len(aString) == 0:
        return newString
    else:
        newString = aString[1:len(aString) + 1]
        firstLetter = aString[0]
        #print(firstLetter)
        if firstLetter in "aeiouAEIOU":

            return removeVowels9(newString)
        else:
            newString = newString + firstLetter
            print(newString)

            return removeVowels9(newString)

A:

Clearly you are never hitting the base case, because you would get a NameError (newString hasn't been defined).
Why? Let's look at your third case:
else: # starts with consonant
    newString = newString + firstLetter # add first letter to the end?
    return removeVowels9(newString) # repeat

once you've removed all of the vowels, this just keeps on looping the consonants, as you should have seen from your outputs:
>>> removeVowels9("University")
iversityn
ersitynv
sitynvr
itynvrs
ynvrst # all vowels gone
nvrsty
vrstyn
rstynv
stynvr
tynvrs
ynvrst # just keeps looping
...

Here is the minimal fix:
>>> def removeVowels9(aString):
    if len(aString) == 0:
        return aString # aString, not newString
    else:
        newString = aString[1:len(aString) + 1]
        firstLetter = aString[0]
        #print(firstLetter)
        if firstLetter in "aeiouAEIOU":

            return removeVowels9(newString)
        else:
            return firstLetter + removeVowels9(newString) # add first letter back at start, after processing rest

>>> removeVowels9("University")
'nvrsty'

But this could be much neater:
def remove_vowels(s):
    """Recursively remove vowels from the input."""
    if not s: # empty string
        return s
    elif s[0] in "aeiouAEIOU": # first character is vowel
        return remove_vowels(s[1:]) # skip first character and process rest
    return s[0] + remove_vowels(s[1:]) # return first character and process rest

Which does:
>>> remove_vowels("University")
'nvrsty'

Note compatibility with the style guide for variable names etc..

