if-else with '|' operator - beginner's question/problem

Skip Montanaro skip at pobox.com
Wed Aug 8 19:51:02 CEST 2001

    if (fname[1] == 'a'|'e'|'i'|'o'|'u'):

Try this instead:

    if fname[1] in "aeiou":
        vowel = "true"

or if you're not married to the vowel="true" bit:

    vowel = fname[1] in "aeiou"

seems somewhat cleaner to me.  It will have a value of 1 (true) or 0 (false)
depending on the value of the "in" expression.

Skip Montanaro (skip at pobox.com)

More information about the Python-list mailing list