Evaluate multiple variables in one 'if' statement?

前端 未结 8 2261
后悔当初
后悔当初 2020-12-05 15:50

Say I have a bunch of variables that are either True or False. I want to evaluate a set of these variables in one if statement to see if they are

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 15:54

    >>> not any([False, False])
    True
    >>> not any([True, False])
    False
    >>> 
    

    Use the any() keyword.

提交回复
热议问题