Syntax for an If statement using a boolean

前端 未结 1 1949
清酒与你
清酒与你 2021-01-04 01:51

I just recently joined the python3 HypeTrain. However I just wondered how you can use an if statement onto a boolean. Example:

RandomBool = True
# and now          


        
相关标签:
1条回答
  • 2021-01-04 02:24

    You can change the value of a bool all you want. As for an if:

    if randombool == True:
    

    works, but you can also use:

    if randombool:
    

    If you want to test whether something is false you can use:

    if randombool == False
    

    but you can also use:

    if not randombool:
    
    0 讨论(0)
提交回复
热议问题