Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Determining if Something is in Order

$
0
0
I have a function that is supposed to determine if the three values given are in order.
def InOrder(CardCollection):
    """
    Determines if a CardCollection is in order
    """
    a = int(CardCollection.cards[0].getFaceVal())
    b = int(CardCollection.cards[1].getFaceVal())
    c = int(CardCollection.cards[2].getFaceVal())
    if a <= b and b <= c: # If its in order from greatest to least
        return True
    elif c >= b and b >= a: # If its in order from least to greatest
        return True
    else:
        return False



It is supposed to determine if they are in either ascending order or descending order. If they are in order Player 1 is supposed to win, and if they're not Player 2 is supposed to win. But for some reason Player 2 wins every time, even if they are in order.
This is what I have at the after the order has been determined.
if InOrder(hand) == True:
            print(Player1 + " You win this play!")
            for i in range(3): # Adds the face value of the cards in hand to Player 1s total
                player1winTotal = player1winTotal + int(hand.cards[i].getFaceVal())
            for i in range(3): # Adds the cards to the wincards list
                player1wincards.append(hand.cards[i])
                
        else:
            print(Player2 + " Won this play!")


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>