anti_vowel problems with conditional


I don't quite understand why this doesn't work:

	if ((char.upper() != "A") or (char.upper() != "E") or (char.upper() != "I") or (char.upper() != "O") or (char.upper() != "U")):

Python does not appear to be evaluating this conditional as I would expect it to. Any insight would be appreciated.


I personally would just simplify that a tad bit,

def anti_vowel(input_):
    return ''.join((letter for letter in input_.lower() if letter not in 'aeiou'))


from re import sub
def anti_vowel(input_):
    return sub(r'[AEIOUaeiou]', '', input_)


def anti_vowel(input_):
    temp = []
    for letter in input_:
        temp.append(letter) if letter.lower() not in 'aeiou' else ''
    return ''.join(temp)


Thanks, I like the regular expression solution. I figured my code out:

if false or false or false or true or false: will evaluate as false

To make it work it needs to use the and operator to evaluate correctly.

if ((char.upper() != "A") and (char.upper() != "E") and (char.upper() != "I") and (char.upper() != "O") and (char.upper() != "U")):