Comparing True False confusion

前端 未结 3 1800
执笔经年
执笔经年 2020-12-19 05:57

I have some confusion over testing values that are assigned False, True

To check for True value, we can simply just

a = True
if (a):
<
3条回答
  •  天命终不由人
    2020-12-19 06:10

    use not:

    if not a:
        ....
        # If a is the empty value like '', [], (), {}, or 0, 0.0, ..., False
        # control flow also reach here.
    

    or is False:

    if a is False:
        ....
    

提交回复
热议问题