I have a python list
list1 = ['TC_TEST1', 'TC_TEST1_TEST2', 'TC_TEST3', 'TC_TEST1TEST2']
sublist1 = ['TEST1', 'TEST3']
Desired output is
result = ['TC_TEST1', 'TC_TEST3']
It should not contain patterns in sublist1 that occur in middle or other places in the string.
I tried using
result = [s for s in list1 if any(xs in s for xs in sublist1)]
but this also prints the patterns wherever it occurs in the string, not only the ending part.