[Tutor] (no subject)

Kent Johnson kent37 at tds.net
Thu Sep 10 16:42:36 CEST 2009


On Thu, Sep 10, 2009 at 9:54 AM, shellcom3 at juno.com <shellcom3 at juno.com> wrote:
> I want to display all the cards in a deck of playing cards using two tuples for all the possible suits.
>
>
>
> value = ("A","2","3","4","5","6","7","8","9","10","J","Q","K")
>
> suit = ("c","h","s","d")
>
> deck = value[0:1] + suit[0:1]
> for item in deck:
>    print item

See itertools.product(), you can use it directly or use a nested list
comprehension as shown in the docs:
http://docs.python.org/library/itertools.html#itertools.product

Kent


More information about the Tutor mailing list