python - nested loop in list comprehension -


i have list of words in l if of exists in first index of each tuple in l2, remove entire tuple.

my code:

l = ['hi', 'thanks', 'thank', 'bye', 'ok', 'yes', 'okay'] l2 = [('hi how u', 'doing great'), ('looking me', 'please hold')] l3 = [k k in l2 if not any(i in k[0] in l) ] 

somehow code not work , empty list l3.

i want

l3 = [('looking me', 'please hold')] 

split k[0] list of words:

[k k in l2 if not any(i in k[0].split() in l)] 

this way checks if i matches word exactly.

it interpreted if k[0] not starts of l, can this:

[k k in l2 if not k[0].startswith(tuple(l))] 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -