我需要幫助找到一個python函數,它只會顯示元組中的值,(x)次數。python只顯示循環中的元組元素x的時間量
from random import *
rankName = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")
suit = ("hearts", "diamonds", "spades" , "clubs")
users = ("I", "computer", "deck")
NUMCARDS = 52
DECK = 0
PLAYER = 1
COMP = 2
count = 0
while (count < 52):
for u in rankName:
for i in suit:
count = count + 1
w = choice(users)
''' 'computer' and 'I' should only show 5 times, while deck shows 42 cards '''
print count, '\t| ', u,' of', i, '\t|', w
感謝。
你沒有的功能,雖然/ – khajvah 2015-04-05 17:12:04
對不起,我的意思方法......我試過數(),但它只會從元組中打印出現一次,從元組中循環1個值。 – SicLeaf 2015-04-05 17:21:49
while循環是多餘的。它會在沒有它的情況下循環適當的時間。 – 2015-04-05 17:35:25