我有点卡住了 for 循环 - 我可以看到它正在做的事情看起来是正确的,但并不是我想要用它完成的事情。我来自 C 背景,但这里的任何建议都是有益的。
def deal(player_num, cards):
a = 0
z = 0
i = 0
b = 0
c = player_num
hand = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
for a in range(player_num):
hand[a] = cards[i] + cards[i+b+c]
b == b+1
i == i+1
z == z+1
return hand
所以 ,for a in range(player_num)
似乎正在工作(追加a++
)但是hand[0]
,hand[1]
等得到了同样的帮助。我猜它循环 a 但不是其他变量,所以我需要使用超过 1 个嵌套循环来获取i++
,b++
和c++
?