我已经设置了所有52张卡,并且我尝试使用for loop
打印所有52张卡。 我不知道如何设置我的for loop
在这一点上。如何使用循环打印卡片?
def define_cards(n):
rank_string = ("ace","two","three","four","five","six","seven","eight","nine","ten","jack","queen","king")
suit_string = ("clubs","diamonds","hearts","spades")
cards = []
for suit in range(4):
for rank in range(13):
card_string = rank_string[rank] + " of " + suit_string[suit]
cards.append(card_string)
print "The cards are:"
for i in range(52): #how to make this for loop work??
print i, card_string[i]
我想打印这样
The crads are:
0 ace of clubs
1 two of clubs
2 three of clubs
...
49 jack of spades
50 queen of spades
51 king of spades
这是一个班轮:'卡=枚举(秩+ '的' +西装套装中的军装)' - 详情请参阅回答 – ninjagecko 2011-05-05 09:57:11
请用[家庭作业]标记标记作业。 – 2011-05-05 10:02:30