Is there an easy one-line way to see if a list of strings contains at least one occurance of a substring? E.g.
string_list=["PG2213-006B","PG0231+051E","PG2213-006A"]
substring_list=["PG2213-006","PG0231"]
I really don't want to loop, as I loop too many times in my code already.
Here's the way it is now:
images is a list of image names
refdict contains full names as keys
hdrs contains some of those keys but truncated
Expand|Select|Wrap|Line Numbers
- for image in images:
-
for x in refdict.keys():
if x.find(hdrs[image]['some keyword']) != -1:
print "Already have that key, skipping image."
I tried with something like
Expand|Select|Wrap|Line Numbers
- if x.find(hdrs[image]['some keyword']) !=-1 for x in refdict.keys():
any help will be greatly appreciated!