I've the following list:
my_list = ['a', 'b', 'c']
I've the following list of strings:
my_strings = ['azz', 'bzz', 'czz']
I'm doing the following to determine if any items of my_list
are in contained within a item in my_strings
:
for my_string in my_strings:
if any(x in my_string for x in my_list):
# Do Stuff
What's the best practice for retaining the x
as found in my_list
so that I might be able to then do the following:
#Do Stuff
new_var = my_string.split('x')[1]
The desired result would be able to assign zz
to new_var
by determining that a
from my list was in azz
from my_strings