I was doodling at the interpreter:

>>> fruit = ["apples","pears","oranges"]
>>> for f in fruit:
...     if f != "apples":
...             print f
...             print "This is not an apple."
...
pears
This is not an apple.
oranges
This is not an apple.

What I can't remember is what is 'or' in python.  For
example, what if I want the loop to skip apples and
pears?  I tried this:

>>> for f in fruit:
...     if f != "apples" or "pears":
...             print f
...             print "This is not an apple or pear"
...
apples
This is not an apple or pear
pears
This is not an apple or pear
oranges
This is not an apple or pear
>>>

Actually maybe my problem is not asking the right
question?  Should I be looking for 'and' instead of
'or' ?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to