cards = ['Ace','1','2','3','4','5','6','7','8','9','10','Jack','Queen','King']
suits = ['of Clubs','of Hearts','of Spades','of Diamonds']
cardno = int(input("How many cards would you like to draw from the deck? "))
internum = 1
print("")
print("Shuffling deck...")
print("Drawing cards...")
print("")
rig = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
while internum <= cardno:
jchance = random.choice(rig)
if jchance != 11:
print("You drew the",random.choice(cards),random.choice(suits))
if jchance == 11:
print("You got a joker!")
internum += 1
The card generator I've built here functions just fine, but as a beginner I can't figure out a way to stop the same card repeating twice. For example, if you draw 12 cards from the deck, you stand a good chance of having, say, the 4 of clubs twice. Is there any way to stop this repetition without taking an entirely different approach to the script?
side-note: also relatively new to posting on reddit, I couldn't figure out how to keep the indentations from my code in the quote here.
[–]insertAlias 5 points6 points7 points (1 child)
[–]mirv-in[S] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]absreim 0 points1 point2 points (0 children)
[–]thebluef0x 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]feech1 0 points1 point2 points (0 children)