Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Checking for 2 different strings in the same list

What I mean by that is, that I want to take a list, let’s say"

["i","am","you","pure","fact"], 

then check whether this list contains 2 different strings, like "i" and "pure", and then if true, it runs something.
This is what I am looking for, but in PYTHON.
I don’t know how to do this sort of check.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this out

elements = ["i","am","you","pure","fact"]
str1 = "i"
str2 = "pure"

if str1 in elements and str2 in elements:
    # Execute code
    ...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading