python method to filter vowels in a string
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
python method to filter vowels in a string
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
python program to find vowels in a string
def check_for_any_vowel(word:str):
if word == None or word == "":
raise Exception("The argument 'word' is None or empty")
word = word.upper()
vowelfound = False
vowels2 = ['A', 'E', 'I', 'O', 'U']
for char in word:
if vowels2.__contains__(char):
vowelfound = True
break
else:
continue
return vowelfound
print(check_for_any_vowel('World'))
print(check_for_any_vowel("qwrrty"))
try:
check_for_any_vowel(None)
check_for_any_vowel("")
except Exception as error:
print("Execption occoured",error)
#------------------------------------------------------------------------------
def find_all_vowels(Word: str):
if Word == None or Word == "":
raise Exception("The arguments 'Word' is None or empty")
vowles_in_Word = []
Word = Word.upper()
Vowles_list = ["A","E","I","O","U"]
for character in Word:
if character in Vowles_list:
vowles_in_Word.append(character)
vowles_in_Word = tuple(vowles_in_Word)
return vowles_in_Word
print(find_all_vowels("ahkiojkl"))
try:
find_all_vowels(None)
find_all_vowels("")
except Exception as error:
print("Execption occoured",error)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us