I am developing a blackjack game in python and am currently working on a function to deal cards but am receiving the following error "TypeError: '>=' not supported between instances of 'list' and 'int'". I have pasted the python code below.
import random
from numpy import random
def draw_card():
'''
This function will generate a random card from a deck of 52 cards
- the suit is random, the card num is also random: 1-13 with equal opportunity
- input: none
- return: String card_suit, Integer card_num
'''
list_number=[]
list_suit=[]
card_number = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'A','J', 'Q', 'K'] #deck of cards
suit = ['H','S','C','D'] #Type of suites
for x in range(0,10):
random.choice(1,52) #Generate a deck of 52 cards
if card_number >= 1 and card_number <= 13:
card_suit=suit[0]
list_number.append(card_number)
list_suit.append(card_suit)
elif card_number >= 14 and card_number <= 26:
card_suit=suit[1]
list_number.append(card_number)
list_suit.append(card_suit)
elif card_number >= 27 and card_number <= 39:
card_suit=suit[2]
list_number.append(card_number)
list_suit.append(card_suit)
elif card_number >= 40 and card_number <= 52:
card_suit=suit[3]
list_number.append(card_number)
list_suit.append(card_suit)
# test
list_suit, list_number = draw_card()
print(list_suit, list_number)
Aucun commentaire:
Enregistrer un commentaire