2021年4月25日星期日

How can you filter between two lists using a function in Python?

I am attempting to get Python to filter values between two lists. It is pasting the values of the original list and ignoring the instructions. Thanks in advance for your input.

string_val = ['Tom','Kyle','Carl','Tom','Mike','Austin'] delval = ['Tom','Kyle']

def filter_list(string_val, delval): new_string =[] for v in string_val: if (string_val) != (delval): new_string.append(v) return new_string

result = filter_list(string_val, delval) print(result)

https://stackoverflow.com/questions/67260348/how-can-you-filter-between-two-lists-using-a-function-in-python April 26, 2021 at 11:07AM

没有评论:

发表评论