Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help! Lists
#8
Another way (requires 3.8 <= Python, otherwise assigning 'hand' should be on separate row):

from random import sample
from itertools import product


suits =  ["Clubs", "Diamonds", "Hearts", "Spades"]
ranks =  ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"]
deck = {' of '.join(card) for card in product(ranks, suits)}
hands = list()
for i in range(5):
    deck = deck.difference(hand := sample(deck, 5))
    hands.append(hand)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Help! Lists - by bwdu - Apr-03-2020, 11:44 AM
RE: Help! Lists - by Mateusz - Apr-03-2020, 12:28 PM
RE: Help! Lists - by deanhystad - Apr-03-2020, 12:54 PM
RE: Help! Lists - by bwdu - Apr-03-2020, 03:07 PM
RE: Help! Lists - by deanhystad - Apr-03-2020, 06:28 PM
RE: Help! Lists - by bwdu - Apr-04-2020, 10:12 AM
RE: Help! Lists - by deanhystad - Apr-04-2020, 01:08 PM
RE: Help! Lists - by perfringo - Apr-05-2020, 06:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,407 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,311 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

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