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

William Park opengeometry at yahoo.ca
Wed Aug 8 19:49:15 CEST 2001

On Wed, Aug 08, 2001 at 06:25:31PM +0100, Lee wrote:
> Hi there, I wonder if someone could possibly tell me what is wrong with
> the following statement. I'm extremely embarrased to ask but here
> goes...
> >>>  if (fname[1] == 'a'|'e'|'i'|'o'|'u'):
>     vowel='true'

'|' is bit-wise operator which operates on plain/long integers only.
What you want is
    if (fname[1] == 'a' or fname[1] == 'e' or ...):
    if (fname[1] in 'aeiou'):

William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc.

More information about the Python-list mailing list