Last active
September 21, 2025 14:36
-
-
Save jasoncartwright/a4dc1d5a78a1388d5e54e8673c1a2946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| pack = [] | |
| number_cards = range(2,10) | |
| face_cards = ['J', 'Q', 'K', 'A'] | |
| suits = ['❤️', '♦️', '♣️', '♠️'] | |
| for suit in suits: | |
| for card in number_cards: | |
| pack.append(f"{card}{suit}") | |
| for card in face_cards: | |
| pack.append(f"{card}{suit}") | |
| pack_1 = pack.copy() | |
| pack_2 = pack.copy() | |
| is_match = False | |
| tries = 1 | |
| while not is_match and pack_1 and pack_2: | |
| pick_1 = random.choice(pack_1) | |
| pack_1.remove(pick_1) | |
| pick_2 = random.choice(pack_2) | |
| pack_2.remove(pick_2) | |
| print(f"Attempt #{tries}") | |
| print(f"Player 1 picked: {pick_1}") | |
| print(f"Player 2 picked: {pick_2}") | |
| if pick_1 == pick_2: | |
| print("It's a match!") | |
| is_match = True | |
| else: | |
| print("Not a match. Try again.") | |
| tries += 1 | |
| if not is_match: | |
| print("No match found — one of the packs was exhausted.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment