Possible to have same key pair more than once in a dictonary
<p>I'm creating a blackjack game with a deck of cards like so:<br>
<code>cards = {'ace':[1,11],'2':2,'3':3}...</code> and so on.  </p>

<p>I want to have <code>3</code> decks of cards, so is it possible to have more than one ace, etc.? If so, how? I still want each card to have the keypair of its value, but I don't care if it's in a dictionary. </p>

<p>Using a dictionary type in Python will not allow you to have duplicate keys (<a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" rel="nofollow">see documentation</a>). So it would not be possible to have more than one 'ace' key in any given dictionary.</p>

<p>You didn't give much context as to how you would use the dictionary in your game. Is it used to store all of the cards in the game and to determine the order in which cards are drawn. Or is it simply used to lookup the value of a card that is stored somewhere else in your programme?</p>

<p>If the former is the case then a dictionary is probably not the right data structure to be using as order is not guaranteed (again, <a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" rel="nofollow">see documentation</a>). Consider using a list, where the order of the elements is maintained and duplicate entries are allowed. You could consider creating a Card class which would have name, value, and deck properties, and store instances of this class in the aforementioned list.</p>

<p>If the latter is the case then it doesn't matter how many decks you have, the name-to-value mappings will always remain the same. In this case you don't need more than one copy of the dictionary.</p>

python python-3.x dictionary