Anti vowel


#1
vowels = ["a","e","o","u","i","A","E","O","U","I"]

def check_vowel(letter):
    for i in vowels:
        if letter == i:
            return True
        else:
            return False
    

def anti_vowel(text):
    publish = ""
    for c in text:
        if check_vowel(c) == False:
            publish += c
    return publish

I'm having a tough time getting why this code is not functioning properly. It returns me the full text string instead of the truncated one.


#2

This however seems to be working.

vowels = ["a","e","o","u","i","A","E","O","U","I"]

def check_vowel(letter):
    if letter in vowels:
        return True
    else:
        return False
    

def anti_vowel(text):
    publish = ""
    for c in text:
        if check_vowel(c) == False:
            publish += c
    return publish

So this is solved now.
For people trying to learn something: The reason my first code didn't work because the for loop kept running through all letters and overwrote previously found Boolean values, so the correct one was never passed onto the second function.


#3

@seranow: Hey, Seranow! I'm glad you found the solution for your problem but I'd just like to say something.
The problem with your first code is that you weren't checking all the elements, at the first time the element stored at the variable i wasn't equal to the one in letter, you would return False and that would make the execution of your program go back to where your function was called.

If you either used your else outside your looping instruction, or just the return False it would also work.

But good job finding the issue of it and fixing it! :+1: