How to check a list contained by another list without a loop?

前端 未结 4 1784
攒了一身酷
攒了一身酷 2020-12-31 01:33

As the title mentions,is there any builtins to do this job?I looked for that in dir(list) but got no usable one.Thanks.

4条回答
  •  天涯浪人
    2020-12-31 02:05

    You might want to use a set

    if set(a).issubset(b):
        print('a is contained in b')
    

提交回复
热议问题