即使if语句仍为False,该语句仍会运行

时间:2019-05-14 00:47:34

标签: python

因此,如果if语句为False,它仍然会运行。

我正在尝试查看是否有人拉着脸卡,然后打印出一些东西。但是,即使我知道if语句为False的事实,它仍然可以运行。

pulls card
def deck():
    global rank
    ranks = [ "9", "8", "7",
    "5", "4", "3", "2", "Ace"]

通知等级没有人脸卡

    suits = ["Clubs", "Spades", "Diamonds", "Hearts"]

    for i in range(1):
        rank = random.choice(ranks)

        suit = random.choice(suits)
        # dont allow same card to be played
        card = ("{} of {}").format(rank, suit)
    return card

``````````````````
prints card
``````````````````
def print_card():
    global cardV, card
    if hit_or_stand() == True:
        card = deck()
        print(str(card))

        cardV = []
        cardV.append(rank)
`````````````````
notice that cardV should not be a face card
``````````````
def player_count():

    if cardV == ["King"] or ["Queen"] or ["Jack"]:

        print("it works")

```````````````
and even if it prints 8 of Spades, it still prints "it works"
````````````

0 个答案:

没有答案