Aug-17-2017, 12:52 PM
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.
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.
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
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition