Hello, I'm trying to teach my self programming with python and there
are some basic things that stumps me:
Given this code:
###
list1 = ['arr', 'bre', 'grau', 'lower', 'tudo']
for item in list1:
    if 'arr' in item:
        print list1
###
The output is (as expected):
['arr', 'bre', 'grau', 'lower', 'tudo']

If I change my condition to:
if 'arr' or 'bell' in item:
or to this:
if 'arr' or 'grau' in item:

I get this result:
['arr', 'bre', 'grau', 'lower', 'tudo']
['arr', 'bre', 'grau', 'lower', 'tudo']
['arr', 'bre', 'grau', 'lower', 'tudo']
['arr', 'bre', 'grau', 'lower', 'tudo']
['arr', 'bre', 'grau', 'lower', 'tudo']

Why this? I guess I'm not grasping the use of AND and OR

Thanks,

Eduardo
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to