Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created August 4, 2015 13:45
Show Gist options
  • Select an option

  • Save bekatom/3904e407b08309ec3583 to your computer and use it in GitHub Desktop.

Select an option

Save bekatom/3904e407b08309ec3583 to your computer and use it in GitHub Desktop.
Custom card shuffle withouy shuffle method
from random import randrange
class Card():
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
card_list = [Card("HEARTS", 4),
Card("HEARTS", 6),
Card("DIAMONDS", 3),
Card("DIAMONDS", 1),
Card("DIAMONDS", 9)
]
def my_shuffle(card_list):
for i, card in enumerate(card_list):
index = randrange(0, len(card_list))
card1 = card_list[i]
card2 = card_list[index]
card_list[i] = card2
card_list[index] = card1
return card_list
my_shuffle(card_list)
for card in card_list:
print "Rank %s Suit %s " % (card.rank, card.suit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment