如果我的列表范围从0到9,例如.我如何使用random.seed函数从该范围的数字中随机选择?另外我如何定义结果的长度.
import random
l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
a = 10
random.seed(a)
length = 4
# somehow generate random l using the random.seed() and the length.
random_l = [2, 6, 1, 8]
Run Code Online (Sandbox Code Playgroud) python ×1