[Tutor] Is it possible to...
jfouhy@paradise.net.nz
jfouhy at paradise.net.nz
Mon Aug 15 09:45:58 CEST 2005
Quoting Nathan Pinno <falcon3166 at hotmail.com>:
> Is it possible to create a def that not only deals cards, but also
> assigns a value to each rank, except that the Jacks, Queens, and Kings
> all are the same value as the 10s?
> If this is possible, how should I go about doing this?
Nearly everything is possible; you just have to order your thoughts correctly :-)
In this case, you're looking for a way of mapping from cards to values. Python
has a mapping type built in, called a dictionary. You can read about it here:
http://docs.python.org/tut/node7.html#SECTION007500000000000000000 and here:
http://docs.python.org/lib/typesmapping.html
--
John.
More information about the Tutor
mailing list