Hello everyone and sorry if I’m not in the right section it’s my first time posting here.
I would like to know how you can use a class method in another method. Below you will have an example with the automaticshuffle method where I want to call the shuffle method under a certain condition but it doeszn’t work. How am I supposed to do that?
``import random
class Deck:
def init(self):
cards=
suit=(“Hearts”, “Diamonds”, “Clubs”, “Spades”)
value=(“A”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“J”,“Q”,“K”)
for i in suit:
for j in value:
cards.append((i,j))
random.shuffle(cards)
self.cards=cards
self.suit=suit
self.value=value
def deal(self):
dealt=self.cards.pop()
return dealt
def shuffle(self):
if len(self.cards)<52:
cards=
suit=(“Hearts”, “Diamonds”, “Clubs”, “Spades”)
value=(“A”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“J”,“Q”,“K”)
for i in suit:
for j in value:
cards.append((i,j))
random.shuffle(cards)
self.cards=cards
def automaticshuffle(self):
if len(self.cards)==0:
self.shuffle()``