Thanks Luke. You've helped me out of a jam that I was going to ask without even asking.
 
Nathan
---------------------------------------------------------------
Early to bed,
Early to rise,
Makes a man healthy, wealthy, and wise.
--Benjamin Franklin
-------------------------------------------------------------------
----- Original Message -----
From: luke
Sent: Monday, August 08, 2005 12:38 AM
Subject: [Tutor] deck dealing program

from random import randint
 
def identify_card(n):
    cardname = ""
    royals = ["Jack","Queen","King","Ace"]
    temp = n % 13
    if temp > 8:
        cardname += royals[temp-9]
    else:
        cardname += str(temp+2)
    cardname += " of "
 
    suits = ["Spades","Hearts","Diamonds","Clubs"]
    cardname += suits[n/13]
    return cardname
 
def main():
    deck = range(52)
    cards = []
    while 1:
        x = raw_input("how many cards do you want? ")
        try:
            x = int(x)
        except ValueError:
            print "Invalid value exiting for I have no error code. Please use an int next time."
            raise SystemExit
        if x <= 52 and x >= 0:
            y = 0
            while y < x:
                cards.append(identify_card(deck.pop(randint(0,len(deck)-1))))
                y += 1
            break
    print cards
if __name__ == "__main__":
    main()
 
#Luke


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to