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...
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?
'd' is not a False like value so it is result of the or statement.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.