Find if value exists in multiple lists

后端 未结 4 1299
借酒劲吻你
借酒劲吻你 2021-01-18 18:57

I have 4 list and each element on the list are unique across the 4 list. How do I find if the value exist in one of the list and return which list it exist?

Example

4条回答
  •  隐瞒了意图╮
    2021-01-18 19:09

    If you don't want to use a list comprehension, you can always use a convoluted and verbose lambda expression!

    list(filter(lambda x: value in x, [a,b,c,d]))

    EDIT: Question was updated to ask for var name, not var value

提交回复
热议问题