Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
card 21 trick
#8
You use the ".extend" by using lists. So for example, if "first", "second" and "third" were lists rather than tuples, you could use ".extend" with them, ie "first.extend(iterable)". The "return" is placed at the end of the function and in general returns the results of what happens within the function.

def mult(x, y):
    result = x * y
    return result

no_1 = 2
no_2 = 4
product = mult(no_1, no_2)
print(product)
In your situation, it's not just that you know how the trick is played, but also the math on which the trick is based. Here is a pretty good explanation of that math: Math behind 21 Card Trick.

If it were me, I would start with a main list of all 21 cards, and first, second, third start as empty lists which could be filled at a later time (within a function), you need to deal the cards, display the cards, ask for user choice, collect the cards (each step 3 times), finally reveal the eleventh card.

To be honest, I can't help but feel that either your answer or perhaps some snippets from the assignment are based on the program by dylanfw on GH.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition


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 sparkz_alot - Aug-17-2017, 12:52 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,376 Apr-11-2019, 12:55 PM
Last Post: Muzz
  card dealer school project kalle1234 5 12,191 Jan-05-2019, 09:21 PM
Last Post: ichabod801
  Playing Card Sorting ness828 4 87,247 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