Python Logic in searching String

Posted by Mahmoud A. Raouf on Stack Overflow See other posts from Stack Overflow or by Mahmoud A. Raouf
Published on 2011-02-27T07:23:16Z Indexed on 2011/02/27 7:24 UTC
Read the original article Hit count: 212

Filed under:
|
filtered=[]
text="any.pdf"
if "doc" and "pdf" and "xls" and "jpg" not in text:
    filtered.append(text)
print(filtered)

This is my first Post in Stack Overflow, so excuse if there's something annoying in Question, The Code suppose to append text if text doesn't include any of these words:doc,pdf,xls,jpg. It works fine if Its like:

if "doc" in text:
elif "jpg" in text:
elif "pdf" in text:
elif "xls" in text:
else:
    filtered.append(text)

© Stack Overflow or respective owner

Related posts about python

Related posts about logic