I have a list a:
a = ['2005', '2006']
and list b:
b = ['2005.123', '2005.234', '2006.123', '2007.234']
If I wanted a list of all the elements in b that contains a string '2005', I would do:
[value for value in b if '2005' in str(value)]
But I would like a list of all the values in b that contain either of the string values in list a (list a and b can be several elements long), and this one does not work:
[value for value in b if ['2005', '2006'] in str(value)]
I would like the code to return
['2005.123', '2005.234', '2006.123']
Is there an easier way to do this, without using loops?