Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
card 21 trick
#14
(Aug-18-2017, 06:41 PM)SummoningZ Wrote: Im not asking you to do it for me im just asking for some kind of idea of what im doing as all the stuff you are saying means nothing to me.

Pack =["JS","4C","KC","3H","5H","AD","10H","9H","7S","JD","6D","JC","2D","QC","5C","JH","4S","QS","8D","9D","4H"]
First = Pack[0:7]
Second = Pack[7:14]
Third = Pack[14:21]

print("1: " + " ".join([str(Pack) for Pack in First]))
print("2: " + " ".join([str(Pack) for Pack in Second]))
print("3: " + " ".join([str(Pack) for Pack in Third]))
This is what I have done so far, is this how it should look?

For starters, printing a list can be easier than making a new list. Instead of print("1: " + " ".join([str(Pack) for Pack in First])), you can do print("1: " + " ".join(First)). It's simpler, and hopefully easier for you to understand.

But aside from that, the Pack only has 21 elements in it. I think the first step would be to have a whole deck, shuffle it, and take the first 21 cards from it as the pack. Something like this (though, you might want to replace itertools with something, so it doesn't look like someone else did it for you :p ):
import itertools
import random

# all four suits
suits = "DCHS"
# all 10 numbers, and also Jack Queen King Ace
numbers = list(map(str, range(2, 11))) + list("JQKA")
# build a full deck of 52 cards
full_deck = ["".join(pair) for pair in itertools.product(numbers, suits)]
print(full_deck)
# shuffle the deck, so it's randomized
random.shuffle(full_deck)
print(full_deck)

# get a pack of the first 21 cards in the shuffled deck
pack = full_deck[:21]
print(pack)


Messages In This Thread
card 21 trick - by SummoningZ - Aug-16-2017, 05:50 PM
RE: I need help with my coding - Python 3 - by nilamo - Aug-18-2017, 08:08 PM
RE: card 21 trick - by metulburr - Aug-22-2017, 04:54 PM
RE: card 21 trick - by SummoningZ - Aug-22-2017, 07:56 PM
RE: card 21 trick - by SummoningZ - Aug-24-2017, 10:30 AM
RE: card 21 trick - by metulburr - Aug-24-2017, 12:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Graphics Card Values in a List Muzz 0 2,379 Apr-11-2019, 12:55 PM
Last Post: Muzz
  card dealer school project kalle1234 5 12,208 Jan-05-2019, 09:21 PM
Last Post: ichabod801
  Playing Card Sorting ness828 4 87,307 Feb-05-2018, 09:01 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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