Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:42:02+00:00 2026-06-10T22:42:02+00:00

I am trying to write a blackjack program, but when I try to send

  • 0

I am trying to write a blackjack program, but when I try to send a message from my deck object to another object that uses .append(), I keep getting an AttributeError: object has no ‘append’

Here’s what code I think is relevant:

class Deck(Hand):

    def deal(self, players, per_hand= 1):
        for rounds in range(per_hand):
            for hand in players:
                if self.hand:
                    top_card = self.hand[0]
                    self.give(top_card,hand)

The players parameter is a tuple of objects I instantiated using:

class Bj_player(Player,Hand):

    def __init__(self,name,score= 0,status= None):
        self.name = name
        self.score = score
        self.status = status
        self.hand = Hand()

the Player base class has nothing in it but a few inputs from the user. Is the above where I’m getting it wrong?

class Hand(object):
"""a hand of cards"""


    def __init__(self):
        self.hand = []

    def add(self, card):
        self.hand.append(card)


    def give(self,card,other_hand):
        if self.hand:
            self.hand.remove(card)
            other_hand.add(card)
        else:
            print("EMPTY ALREADY. COULD NOT GIVE")

I took out the str part to cut it down. The error I’m getting is this:

 line 44, in add
    self.hand.append(card)
    AttributeError: 'Hand' object has no attribute 'append'

I’m pretty new so the more simply explained the better. Thanks.

Also, just in case it’s helpful, here’s how I’m starting things out:

deck = Deck() #populated and all that other stuff

total_players = Player.ask_number("How many players will there be? (1-6): ",1,6)
for player in range(total_players):
    name = input("What is the player's name? ")
    x = Bj_player(name)
    roster.append(x)

deck.deal(roster,2) #error =(
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:42:03+00:00Added an answer on June 10, 2026 at 10:42 pm

    The problem is the line:

            self.hand = Hand()
    

    within the Bj_player class. That makes the self.hand variable a Hand instance, rather than a list as it should be. roster is a list of these BJ_player instances, so when you call deck.deal(roster), and within the function it says for hand in players, each hand object will be one of these Bj_player instances.

    The best way to solve this is for Bj_player not to inherit from hand. (Indeed, it’s not clear why you have it inherit from Player, or what useful functionality the Player class provides). Instead, have Bj_player be its own class (perhaps named Player instead- less confusing) and change the line

        for hand in players:
            if self.hand:
                top_card = self.hand[0]
                self.give(top_card,hand)
    

    to

        for player in players:
            if self.hand:
                top_card = self.hand[0]
                self.give(top_card,player.hand)
    

    A separate note: if you changed self.hand to self.cards, it would make things a lot clearer!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying write a function that generates simulated data but if the simulated
I'm trying write a simple perl script that reads some fields from a password
Im' trying to write a class BrokenObjectException class derivated from Exception. But in Eclipse
Trying to write a python application that downloads images from an RSS feed, and
I'm trying write a C program that sends an UDP packet to a given
I'm trying write a program that takes a list of names, sorts those names,
I'm trying write a java program to send live microphone data over UDP, then
I'm trying write a program that takes a list of names, sorts those names,
I m trying write code that after reset set up rrpmax as 3000. It
Trying to write app for service technicians that will display open service calls within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.