I just learn python today, and so am thinking about writing a code about recursion, naively. So how can we achieve the following in python?
class mine:
def
This is a code example that actually works
class Card():
def __init__(self,cardsPlayedList,cardPosition):
self.cardsPlayedList = cardsPlayedList
self.cardPosition = cardPosition
# self.cardPosition
def getNewCard(self,cardPosition):
cardNum = 0
cardInList = False
cardNum = random.randint(1,len(cardList)-1) # Get random card from List - 1 to 52
for x in self.cardsPlayedList:
if(cardNum == x):
cardInList = True
if(cardInList == False):
self.cardsPlayedList.insert(self.cardPosition, cardNum) # if card not already played then store in list
return cardNum
else:
return self.getNewCard(cardPosition)