"Vincent Balmori" <vincentbalm...@yahoo.com> wrote
I keep getting a Type Error since for the moment since the
values of the cards cannot be compared due to their
types.
Please send the complete error text sincethat will tell us
where to look etc.
I am thinking of creating a Card_Value class that will give each
rank
and suit a certain value. If there is also a more elegant way of
handling
some of the code in the main section that will be welcome.
You can get cards to compare themselves by adding a few
more "magic methods". Then you can do stuff like
if card1 < card2:
# ....
elif card2 > card1:
# ....
else:....
The methods you need to create are
__gt__(), __lt__(), __eq__(), __le__(), __ge__()
for
,<,==,<=,>=
operations.
BTW, In your code you have a comparison using = instead of ==.
That will fail.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor