Hi ,

I want to achieve something like this .

Consider the example

>>> txt
'arin.thearc@gmail.com'

if '@' or '.' in txt:
              do something

I just want to know how can we nest ORs and ANDs inside the if or while loops...

OOps , i got it.........

We can use 'or' and 'and' keywords............

>>> if '@'or '.' or 'i' in txt:
	print "yes"
else:print "no"

yes

wrong, check again

a = 'abc'
print 'd' or 'e' in a
print 'd' in a or 'a' in a
print any(c in a for c in 'da')

wrong, check again

a = 'abc'
print 'd' or 'e' in a
print 'd' in a or 'a' in a
print any(c in a for c in 'da')

@pytony........Hi Sir,
....I ran all of the above statements and the results are disturbing....

>>> a='abc'
>>> print 'd' or 'e' in a
d
>>> print 'd' in a or 'a' in a
True
>>> print any(c in a for c in 'da')
True

Please tell me whats happening here....This might create serious problems in my software i am trying to build....

@pytony........Hi Sir,
....I ran all of the above statements and the results are disturbing....

>>> a='abc'
>>> print 'd' or 'e' in a
d
>>> print 'd' in a or 'a' in a
True
>>> print any(c in a for c in 'da')
True

Please tell me whats happening here....This might create serious problems in my software i am trying to build....

I tried this too:

>>> Pattern="sdfdfg"
>>> if '\\'or '^' or '.' in Pattern:
	print "yes"
else:print "no"

yes

I cant figure out why is this happening?

Edited 4 Years Ago by arindam31: n/a

This question has already been answered. Start a new discussion instead.