Skip to content

Commit

Permalink
Fix loop bug in deck of cards exercise (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
joilson-cisne committed Jul 8, 2020
1 parent 0beb557 commit 06b3ed2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"\n",
" def score(self):\n",
" total_value = 0\n",
" for card in card:\n",
" for card in self.cards:\n",
" total_value += card.value\n",

This comment has been minimized.

Copy link
@verma-rudresh

verma-rudresh Nov 19, 2021

it would be better if we write card.value() (encapsulated function)

" return total_value\n",
"\n",
Expand Down

2 comments on commit 06b3ed2

@verma-rudresh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 126, it would be better if we write card.value() (encapsulated function)

@EddieMG
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of "self" missing in the Deck class.

class Deck(object):

    def __init__(self, cards):
        self.cards = cards
        self.deal_index = 0

    def remaining_cards(self):
        return len(self.cards) - self.deal_index

    def deal_card(self):
        try:
            card = self.cards[self.deal_index]
            card.is_available = False
            self.deal_index += 1
        except IndexError:
            return None
        return card

Please sign in to comment.