Jump to content

Integer comparision

- - - - -

  • Please log in to reply
No replies to this topic

#1
yamman13

yamman13

    Learning Programmer

  • Members
  • PipPipPip
  • 56 posts
I'm using a function in a card game, to check the value of each card, and see if it is higher than the last card played.

def Valid(card):

    prev=pile[len(pile)-1]

    cardValue=0

    prevValue=0

    if card[0]=="J":

        cardValue=11

    elif card[0]=="Q":

        cardValue=12

    elif card[0]=="K":

        cardValue=13

    elif card[0]=="A":

        cardValue=14

    else:

        cardValue=card[0]

    prevValue=prev[0]

    if cardValue>prevValue:

        return True

    elif cardValue==prevValue:

        return True

    else:

        return False



The problem is, whenever I get a facecard, it doesnt seem to work.
I've used lots of print statements, and the result is something like this:

Quote

cardValue: 13 previouscardValue: 3 card>prev card? False
cardValue: 4 previouscardValue: 3 card>prev card? True

the first one is a king, so it gets the value 13
the second is just a normal 4




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users