Python Forum
Using two functions to shuffle a deck of cards
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using two functions to shuffle a deck of cards
#4
There is method in random module that is almost named for a deck of card shuffle.
>>> from random import shuffle

>>> deck = [rank + suit for rank in "23456789TJQKA" for suit in "scdh"]
>>> shuffle(deck)
>>> # Deal 5 card
>>> deck[:5]
['4s', '7h', 'Qc', 'Qs', '5c']
Reply


Messages In This Thread
RE: Using two functions to shuffle a deck of cards - by snippsat - Feb-14-2017, 08:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to compare two cards games? python_beginner99 7 3,816 Nov-30-2021, 06:53 PM
Last Post: deanhystad
  sorting a deck of cards (objects in a list) itmustbebunnies 1 7,261 Dec-05-2018, 02:44 AM
Last Post: ichabod801
  Random Shuffle List simon 10 10,255 Oct-24-2016, 04:02 PM
Last Post: simon

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020