Jan-10-2021, 12:16 PM
First, bad idea to have a variable named the same as a keyword (list).
This works. Note the change in the if statement
This works. Note the change in the if statement
test_list = ["bc", "ad", "ac", "cpd"] new_list =[] for x in test_list: if "a" in x and "c" in x: new_list.append(x) print (new_list)