python_打乱已知列表的顺序
import random
def sort():
list_0 = ['A', 'B', 'C', 'D', 'E', 'F', 'G'] # 列表不能设置中间变量(等同于原变量)
list_1 = []
while len(list_0) > 0:
# 随机生成索引
x = random.randint(0, len(list_0) - 1)
list_1.append(list_0[x])
list_0
原创
2021-05-14 21:20:35 ·
165 阅读 ·
0 评论