Capital Group research workflows use compact text labels that may contain letters, digits, spaces, and punctuation. Implement a function that removes vowels, consonants, or both while preserving every retained character in its original order.
Given an ASCII string s and two Boolean flags, return a new string:
remove_vowels is True. Vowels are a, e, i, o, and u, regardless of case.remove_consonants is True.You may use a single left-to-right scan. Do not use regular expressions.
def filter_letters(s, remove_vowels, remove_consonants):