I am trying to find out if there is an way to see how many of an object (count) from one list is in another list.
I have a class Card.
class Card(object):
def __init__(self, number):
self.number = number
def __eq__(self, other):
return self.number == other.number
def getNumber(self, card):
return card.number
I have a class Deck which contains a list of Cards.
class Deck(object):
def __init__(self):
self.cards = []
for i in range(11):
for j in range(i):
self.cards.append(Card(i))
I want to see if a I can get the count of a Card in the Deck.
deck = Deck()
The deck contains 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10
cards = [Card(6), Card(5), Card(3)]
The cards are 6 5 3
I want to know how many 6's, 5's and 3's there are in the deck.