1
 class Deck:
    def __init__(self):
        self.suits = ['S', 'C', 'H', 'D']
        self.nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
        self.deck = []

    def make_deck(self):
        self.deck = [f"{j}{i}" for j in self.nums for i in self.suits]
        return self.deck

    def pop_deck(self):
        for i in range(3):
            self.deck.pop(0)  # gah don't do pop(i), do pop(1)
        return self.deck

full_deck = Deck()
print(full_deck.make_deck())
print(full_deck.pop_deck())


class CardDistribution(Deck):
    def updated_deck(self):
        return self.deck


d = CardDistribution
print(d.updated_deck())

Traceback (most recent call last): File "/Users/fatimah/PycharmProjects/classes/blackjack.py", line 37, in print(d.updated_deck()) TypeError: updated_deck() missing 1 required positional argument: 'self'

3
  • 2
    Missing () on line d = CardDistribution ? Commented Feb 23, 2021 at 4:23
  • I'm trying to edit my code so that it prints the updated deck, but it raises the "self" error-not sure why Commented Feb 23, 2021 at 4:41
  • @Ruan That worked, thanks! Commented Feb 23, 2021 at 4:43

1 Answer 1

1

On-Line 26, You forgot to add () when defining the object. Updated Code will be:-

class Deck:
    def __init__(self):
        self.suits = ['S', 'C', 'H', 'D']
        self.nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
        self.deck = []

    def make_deck(self):
        self.deck = [f"{j}{i}" for j in self.nums for i in self.suits]
        return self.deck

    def pop_deck(self):
        for i in range(3):
            self.deck.pop(0)  # gah don't do pop(i), do pop(1)
        return self.deck

full_deck = Deck()
print(full_deck.make_deck())
print(full_deck.pop_deck())


class CardDistribution(Deck):
    def updated_deck(self):
        return self.deck


d = CardDistribution()
print(d.updated_deck())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.