Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Basic Object-Oriented Python Creating a Memory Game Card Class

TypeError: Card() takes no arguments

TypeError: Card() takes no arguments: can't understate where is the error?

class Card:
    def __int__(self, word, location):
        self.card = word
        self.location = location
        self.matched = False 

    def __eq__(self, other):
        return self.card == other.card

    def __str__(self):
        return self.card

if __name__ == '__main__':
    card1 = Card('egg', 'A1')
    card2 = Card('egg', 'B1')
    card3 = Card('hut', 'D4')

    print(card1 == card2)
    print(card1 == card3)
    print(card1)

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

You've almost got it! Your init statement needs to be fixed. That's all. Good luck with Python!

class Card:
    def __init__(self, word, location): #fixed
        self.card = word
        self.location = location
        self.matched = False 

    def __eq__(self, other):
        return self.card == other.card

    def __str__(self):
        return self.card

if __name__ == '__main__':
    card1 = Card('egg', 'A1')
    card2 = Card('egg', 'B1')
    card3 = Card('hut', 'D4')

    print(card1 == card2)
    print(card1 == card3)
    print(card1)

Silly me! Thanks :)