Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
card 21 trick
#15
Thank you nilamo.

Ok so now I have this import itertools

import itertools
import random
 
suits = "DCHS"
numbers = list(map(str, range(2, 11))) + list("JQKA")
full_deck = ["".join(pair) for pair in itertools.product(numbers, suits)]
random.shuffle(full_deck)
pack = full_deck[:21]

first = pack[0:7]
second = pack[7:14]
third = pack[14:21]

print("1: " + " ".join(first))
print("2: " + " ".join(second))
print("3: " + " ".join(third))

selection = int(input("> "))
if selection == 1:
  pack.extend(second)
  pack.extend(first)
  pack.extend(third)
elif selection == 2:
  pack.extend(first)
  pack.extend(second)
  pack.extend(third)
elif selection == 3:
  pack.extend(first)
  pack.extend(third)
  pack.extend(second)
  
print("You're thinking of %s" %pack[10])
How do I do the actual trick by choosing the 11th card?


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 SummoningZ - Aug-18-2017, 09:11 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,378 Apr-11-2019, 12:55 PM
Last Post: Muzz
  card dealer school project kalle1234 5 12,200 Jan-05-2019, 09:21 PM
Last Post: ichabod801
  Playing Card Sorting ness828 4 87,285 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