1
2
from random import randint
Representing a deck of cards with two Python dictionaries. The first dictionary represents the card suits with keys of 0 to 3. The second dictionary represents the cards in any given suit with keys of 0-12. The function draw_cards() is called with the number of cards you want to draw. Optionally, you can supply a list of cards that have already been dealt from the possible 52. As with a real deck of cards, you should not be able to draw a duplicate. Therefore, when draw_cards() calls itself, it provides the list_dealt list containing the cards that have already been drawn from the deck. You could go further and make this into a game.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.