我已經設置了所有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