How to check if one of the following items is in a list?

前端 未结 14 2234
终归单人心
终归单人心 2020-11-22 17:02

I\'m trying to find a short way to see if any of the following items is in a list, but my first attempt does not work. Besides writing a function to accomplish this, is the

14条回答
  •  甜味超标
    2020-11-22 17:48

    Simple.

    _new_list = []
    for item in a:
        if item in b:
            _new_list.append(item)
        else:
            pass
    

提交回复
热议问题