sorry if this question seems silly. Ive spent days trying to solve it but cant seem to move!!
I have the following classes for a game of black jack.
class Player:
def __init__(self, player, balance=0):
self.player = player
self.balance = balance
def __str__(self):
return f'Player: {self.player}n Balance: ${self.balance}'
def bet(self):
print(self.balance)
class Dealer(Player):
def __init__(self):
pass
I am trying to call the bet method from Player class through the Dealer class but am getting an error when I print(self.balance)
. I changed this to print(Player.balance)
but this does not work either. Can someone please point me in the right direction. Again sorry but am a beginner in classes!
name = input("Enter your full name: ")
balance =int(input("Enter the amount you would like to place on the table? "))
my_player = Player(name, balance)
my_dealer = Dealer()
my_dealer.bet()
Source: Python Questions