python3 vowels and consonants filter code example

Example 1: python3 vowels and consonants filter

def anti_vowel(c):
    newstr = c
    vowels = ('a', 'e', 'i', 'o', 'u')
    for x in c.lower():
        if x in vowels:
            newstr = newstr.replace(x,"")

    return newstr

Example 2: python3 vowels and consonants filter

def anti_vowel(text):
  new_text = ""
  for i in text:
    if i == 'a' or i == 'A':
      pass
    elif i == 'e' or i == 'E':
      pass
    elif i == 'I' or i == 'i':
      pass
    elif i == 'o' or i == 'O':
      pass
    elif i == 'u' or i == 'U':
      pass
    else:
      new_text = new_text + i
  return new_text

print anti_vowel('Hey look Words!')

Example 3: python3 vowels and consonants filter

def eliminate_consonants(x):
        vowels= ['a','e','i','o','u']
        for char in x:
            if char in vowels:
                print(char,end = "")

eliminate_consonants('mississippi')

Example 4: python3 vowels and consonants filter

def getVowels(text):

vowel_letters = []
vowel_list = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U',]

for vowels in text:
    if vowels in vowel_list:
        vowel_letters.append(vowels)

return vowel_letters

print(getVowels('Hi, How are you today!'))
## Output: ['i', 'o', 'a', 'e', 'o', 'u', 'o', 'a']

Example 5: python3 vowels and consonants filter

letterList = ['a', 'b', 'c', 'd']
vowelList = []

for letter in letterList:
    if letter in 'aeiou':
        vowelList.append(letter)

Example 6: python3 vowels and consonants filter

class Vowels(object):
    def __init__(self, vowelList):
        self.vowelList = vowelList

        lettersList = self.vowelList.s.split(",")
        self.vowelList = [letter for letter in self.lettersList if letter in 'aeiou']

Tags:

Misc Example