I'm writing a text-based Blackjack game in Python 3.5 and have created the following classes and corresponding methods:
import random
class Card_class(object):
def __init__(self):
pass
def random_card(self):
suites = ['clubs', 'spades', 'diamonds', 'hearts']
denomination = ['ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'jack', 'queen', 'king']
card = (suites[random.randint(0, 3)], denomination[random.randint(0, 13)])
return card
def card_check(self, card, cards_distributed):
if card not in cards_distributed:
cards_distributed.append(card)
return True
else:
return False
class Player_hand(object):
def __init__(self):
pass
def cards_held(self, card, cards_holding):
cards_holding.append(card)
return cards_holding
class Distribute_class(object):
def __init_(self):
pass
def initial_card_distribute(self, cards_distributed, player_cards_holding = [], cards_held = 0):
player = ''
while cards_held < 2:
player = Card_class()
result_card = player.random_card()
if not player.card_check(result_card, cards_distributed):
continue
else:
Player_hand.cards_held(result_card, player_cards_holding)
break
return player_cards_holding
I'm attempting to test my code using
distributed_cards = []
player1 = Distribute_class()
player1_hand = player1.initial_card_distribute(distributed_cards)
player1_hand
But I'm given the following error:
TypeError: cards_held() missing 1 required positional argument:
'cards_holding'
The terminal window which presents the error says the error comes from the line containing Player_hand.cards_held(result_card, player_cards_holding)
in the final class, Distribute_class
, listed above. Does this line not recognize that I had given it a default parameter of player_cards_holding = []
defined in the method within the same class? Or is there some sort of other problem coming from the fact that the method generating the error, "cards_held", is being called from another class?