Skip to content

Instantly share code, notes, and snippets.

@christophergregory
Created August 11, 2014 01:11
Show Gist options
  • Save christophergregory/cbdd9c986d15125b09f0 to your computer and use it in GitHub Desktop.
Save christophergregory/cbdd9c986d15125b09f0 to your computer and use it in GitHub Desktop.
Function that returns list of vowels in string
def getVowels(word, includeY=False, unique=False):
matches = []
vowels = 'aeiou' if not includeY else 'aeiouy'
for char in word:
if char.lower() in vowels:
matches.append(char)
return list(set(matches)) if unique else matches
print getVowels('This is a fancy test string', includeY=True, unique=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment