best way to implement a deck for a card game in python

前端 未结 5 416
执念已碎
执念已碎 2020-12-31 05:06

What is the best way to store the cards and suits in python so that I can hold a reference to these values in another variable?

For example, if I have a list called

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 05:32

    You could simply use a number, and decide on a mapping between number and "card". For example:

    number MOD 13 = face value (after a +1)

    number DIV 13 = suit

提交回复
热议问题