Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More consistent way to get suit value and suits length #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ricefryegg
Copy link

Change from using different way to get suit value than rank_value

suit_values = dict(spades=3, hearts=2, diamonds=1, clubs=0)

def spades_high(card):
    rank_value = FrenchDeck.ranks.index(card.rank)
    return rank_value * len(suit_values) + suit_values[card.suit]

To be more consistent. Also we can get suit_values from existing class variable FrenchDeck.suits.

def spades_high(card):
    rank_value = FrenchDeck.ranks.index(card.rank)
    suit_value = FrenchDeck.suits.index(card.suit)
    return rank_value * len(FrenchDeck.suits) + suit_value

@Florimond
Copy link

Florimond commented Aug 26, 2022

Also, I may need glasses, but in the listing page 5, the order of the suits is not the same as the order in suit_values on page 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants