【发布时间】:2020-03-29 21:51:09
【问题描述】:
我一直在尝试遍历一个数组。
下面是代码。
x = ['lemon', 'tea', 'water', ]
def randomShuffle (arr,n):
from random import choices
newList=[]
for item in arr:
r=choices(arr, k=n)
if r.count(item) <= 2:
newList.append(item)
return (newList)
我想知道写它的逻辑。
谢谢大家
【问题讨论】:
标签: arrays python-3.x random