Are you: a.) Having trouble with the code and looking for help? b.) Looking for suggestions on how to improve the code? c.) Offering the code as a demo for Nathan et al.?
I was just doing stuff along the same lines and was having fun seeing the different approaches to the same problem. --Todd On Monday 08 August 2005 02:38 am, luke wrote: > 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