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 Game Class Part 2

kamal diriye
kamal diriye
1,597 Points

for card in self.cards: if card.location == f'{column}{num}': if card.matched:

Can someone please explain to me the 'card.matched' command when we use it here? The complication I am having is that i understand we are checking the cards location to the location within the rows. Then when it comes to the 'if card.matched:' command, how is this command being used to check whether the cards location is correct?

Hopefully the question makes sense.

2 Answers

Hi there kamal diriye , At this point in the course, the matched attribute is false by default and it isn't changed to true in the code just yet. That is why Megan changed them manually when testing the code at the 8min mark of this video. In the next video, the matched attribute will change to true when cards are equal when you build the check_match method in the game class.

Hope this helps!

kamal diriye
kamal diriye
1,597 Points

Thank you! That makes sense now!