Code Exercise
The point of this exercise, was to pass in a string and remove all vowels (except for Y.)
My solution
Similar to the palindrome code, I created an empty list called con_list. Then I use a for loop to check if a value is passed in. For all vowels (except Y) I basically do nothing. Then outside that if, I have an else that appends each remaining car (not caught in the if) to the con_list. Then I use the “”.join(con_list) to construct a string out of the list.
def anti_vowel(text):
con_list = []
for s in text:
if s == "a" or s == "A" or s == "e" or s == "E"\
or s == "I" or s == "i" or s == "O" or s == "o"\
or s == "U" or s == "u":
print("ignoring char")
else:
con_list.append(s)
con_list_cat = "".join(con_list)
print(con_list_cat)
anti_vowel("Hey You!")
No responses yet