Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is python3 I don\'t know why it causes error. Please let me know what the p

ID: 3721499 • Letter: T

Question

This is python3

I don't know why it causes error.

Please let me know what the problem is.

from Lab12 import + import random class BlackjackHand: def _init_(self): se l f . hand = [ ] self.hand_list [ se l f . va lue-l ist- [ ] def add.card(self, new.card) self.hand.append (new_card) def _str_(self) for i in self.hand self.handlist.append (Cardi).get rank) +of "Card(i).get suit)) join(self . hand-list) “ return def get value(self): for i in self.hand? self.value list.append (Card i).get value)) return self.value list class Bl ackj ack def _init_(self, starting dollars): self.bankChipBank(start ing dollars) se l f , deck [ ] for i in range (52): my-card = Card(1 ) self.deck.append(my card) my card.face up() random.shuffle(self.deck) self.player Bl ackjackHand se l f . dealer = BI acki ackhand def draw (self) if len(sel f . deck) = 0: for i in range(52): my cardCard(i) self.deck.append (my card) my card.face up) self . deck randon, shuffle(deck) return self.deck.pop)

Explanation / Answer

In Your blackJackHand file:

in __str__ function:

changle line:

self.hand_list.append(Card(i).get_rank() + ' of ' + Card(i).get_suit())

to
self.hand_list.append(i.get_rank() + ' of ' + i.get_suit())


===========
Reason is:
in for loop call:
for i in self.hand
You are getting card object in i,
and when you do Card(i), then it is trying to initialize a new card object using the card object i, that you passed.

/// Please rate a thumbs up if it solves your issue. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote