Open imahana1109 opened 3 years ago
p.s. note that error is this:
IndexError Traceback (most recent call last)
@imahana1109 this error is happening because calling some_list.pop()
requires some_list to have at least one item. So the problem here isn't actually at the line where the error occurred, but in setting up the deck in __init__()
. At least one of suits
or cards
are not correctly setup, start by checking those values.
@imahana1109 this error is happening because calling
some_list.pop()
requires some_list to have at least one item. So the problem here isn't actually at the line where the error occurred, but in setting up the deck in__init__()
. At least one ofsuits
orcards
are not correctly setup, start by checking those values.
class Card:
def __init__(self,suit,rank):
self.suit=suit
self.rank=rank
self.values=values[rank]
def __str__(self):
return self.rank+ " of "+self.suit
above is card class
import random suits=("Hearts","Diamonds","Spades","Clubs") ranks=("Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King") values = {"Two": 2, "Three":3, "Four":4, "Five":5, "Six":6, "Seven":7, "Eight":8, "Nine":9, "Ten":10, "Jack":11, "Queen":12, "King":13, "Ace":14}
setting up deck
ranks=("Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King")
this line is the problem 🙂
ranks=("Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King")
please correct this line, you will be good to go...
So are you guys saying I forgot Ace in ranks? if you say yes, and if it works, i'll close this issue
print the cards for both players while doing the loop 26 and you will see helpful info
print the cards for both players while doing the loop 26 and you will see helpful info
........ can you type the code in reply idk what you're talking about, and it doesn't work
class Deck:
setup
player_one=Player("One") player_two=Player("Two")
new_deck=Deck() new_deck.shuffle()
for x in range(26): player_one.add_cards(new_deck.deal_one()) player_two.add_cards(new_deck.deal_one()) Note:spaces used to be underscores, this code is from milestone 2 :) please tell me if i did something wrong