The class isn't recognizing its attribute wins, and although I am not actually trying to directly print that value, it gives the same error as what I do want to happen while looking neater.
class deck:
def __init__(self, dname, player, rules, colors, wins, losses, srating):
and then a couple lines down I have this
Alpha = deck("Alpha", "Test", 'GRD', 'Colors', 0, 0, 0)
deck.adddeck(Alpha)
print(Alpha.wins)
which returns this error:
AttributeError: 'deck' object has no attribute 'wins'
as far as I can tell my code looks fine. I've made sure I have no tabs mixed with spaces. I've retyped it 100 times to make sure they are named the same. I have also stripped all the trailing white spaces. It still does not work.
CodePudding user response:
Looks like you did not set them
class Deck():
def __init__(self, dname, wins):
self.wins=wins
self.dname=dname
deck=Deck('A',1)
print(deck.dname, deck.wins)
Should be like this way. Works for me.
CodePudding user response:
turns out I miss understood the basic difference between parameters and attributes. I had my attributes named something different than my parameters which was erroring them out... long story short I'm dumb and I figured it out.
