What I am trying to do is make a deck of cards, then move a specific card from the deck to a player's hand. I am having no trouble moving creating the deck and adding a card to a player's hand, but whenever I try to remove the card from the deck it tells me the card isn't in the deck to begin with, which does not make sense.
Here is the relevant code
class Card(object): suit_names = ["Clubs", "Diamonds", "Hearts", "Spades"] rank_names = [None, "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"] #so zero returns nothing, an Ace is 1 and so forth def __init__(self, suit, rank): #initial method, just defines suit and rank so you can find it later self.suit = suit self.rank = rank def getRank(self): #returns the rank of the card as an integer return self.rank def getSuit(self): #returns suit as an integer return self.suit def __str__(self): return '%s of %s' % (Card.rank_names[self.rank], Card.suit_names[self.suit]) class Deck(object): def __init__(self): #this is just creating a deck of cards, in standard order with the suits arranged alphabetically self.cards = [] for suit in range(4): for rank in range(1, 14): card=Card(suit, rank) self.cards.append(card) #what you should be ending up here is 52 objects from the "Card" class def shuffle(self): shuffle(self.cards) def main(): selfHand=[] s,r=eval(input("Input your first downcard's suit and rank, separated by a comma" )) card=Card(s,r) selfHand.append(card) deck.cards.remove(card) again, everything is working OK (I've omitted the irrelevant code, if anything looks a bit off--that is why there are big indents in the main function) but the last line prompts the error "ValueError: list.remove(x): x not in list"
To be clear, the deck should be a list of cards. I am trying to remove a specific card from the deck, that's it. Thought it would be simple but has eaten up a whole afternoon (to be fair, I am very new to python and coding in general)
I have tried countless different approaches at this point, with similar results.
Thanks for the help
deckwhich is not defined.deck = Deck()that you have forgotten to include here?