我已经和python搞混了几个月。我想知道是否有任何方法可以缩短这段代码?我正在制作纸牌游戏,希望用户能够选择对手的数量。谢谢
def __init__(self,usedCards):
self.cards = [player]
for i in range(52//playerNo):
card = pickCard(usedCards)
cards.append(card)
usedCards.append(card)
playerNo = pushChoice("Pick the number of players you want to play against (up to 5)","integer",1,5)
player2 = player(usedCards)
if playerNo > 2:
player3 = player(usedCards)
if playerNo > 3:
player4 = player(usedCards)
if playerNo > 4:
player5 = player(usedCards)
if playerNo > 5:
player5 = player(usedCards)
if playerNo > 6:
player6 = player(usedCards)```