from random import randint as rand
from random import shuffle
suits = ("Spades","Hearts","Clubs","Diamonds")
class Card:
def __init__(self, rank, suit):
if rank not in range(1, 14):
raise TypeError('Rank must be an integer between 1 and 13.')
if suit not in suits:
raise TypeError('Suit must be a string: "Spades", "Hearts", "Clubs", or "Diamonds".')
# The quick check above makes sure the card being made actually exists in a standard deck of 52.
# If so, the card is created succesfully.
self.rank = rank
self.suit = suit
def draw(): #Acts like drawing a card from a deck
randCard = cardDeck.pop()
return randCard
shuffleDeck()
def dealer():
for i in range(1, 4):
print(drawFaceUp())
def player_hand():
for i in range(1, 3):
print(draw())
dealer()
player_hand()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
output
10 of Hearts
None
3 of Hearts
None
Ace of Diamonds
None
<__main__.Card object at 0x015043D0>
<__main__.Card object at 0x015044F0>
Я не уверен, почему я получаю эти две нижние строки "" "<<strong> main .Card объект в 0x015043D0> <<strong> main .Card объект в 0x015044F0>" «» или почему после, скажем, 3 из «Червей» он продолжает говорить «Нет», у меня есть больше кода, который я использовал, но я уверен, что он не нужен для моего вопроса, если вы хотите увидеть весь мой код, я опубликую его все.