[Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-07 Thread Danny Yoo
Answer: yes, very much so. *grin* Ok, let's take a look at some snippets. ## cd = int(raw_input("How many cards to deal (1-6) or 9 to exit:")) if cd == 1: a = random.choice(range(52)) if a == 0: a = "Ace of Hearts" elif a == 1: a = "T

Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-07 Thread Brian van den Broek
Nathan Pinno said unto the world upon 2005-08-07 22:10: > My message is in the attachment. Nathan, Just one fellow's voice, but I vote for "please don't do that" [the attachment]. It makes it more work to read your message. > Here is the improved algorithm: > import random > a = random.choi

Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-09 Thread Roel Schroeven
Brian van den Broek wrote: > Say you go with your method of defining a deck (cards above) and then > making random choices from it. Try something like this (untested code): > > cards = ["Ace of ...",] # As above > cards_dealt = [] > def get_card(): > while True: > new_card = random

Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved?

2005-08-09 Thread Nathan Pinno
10:03 PM Subject: Re: [Tutor] Use functions re avoid Re: Can the following algorithm be improved? > Nathan Pinno said unto the world upon 2005-08-07 22:10: >> My message is in the attachment. > > Nathan, > > Just one fellow's voice, but I vote for "please don't