Comparison between these two lists and eliminating from List1 if it matches. Is there any way to process the List1 too.
List1: ["'file',", "'ist',", "'customer',"]
List2: ['permission', 'ist', 'dr']
Comparison between these two lists and eliminating from List1 if it matches. Is there any way to process the List1 too.
List1: ["'file',", "'ist',", "'customer',"]
List2: ['permission', 'ist', 'dr']
Seems like a simple list comprehension would do it.
filtered_list = [string for string in List1 if string not in List2]
Warning: your strings in List1 don't match the format of the strings in List2. Not sure if that was your intent. The string 'ist', won't match with the string ist.
str.strip might do it, depending on what other formatting errors are in those strings. cleaned_list_1 = [x.strip(['"', "'", ',']) for x in List1]This will give you the required output.
for i in list(List1):
if i.strip("',") in List2:
List1.remove(i)