小编gat*_*007的帖子

TypeError: 'dict_keys' object does not support indexing

def shuffle(self, x, random=None, int=int):
    """x, random=random.random -> shuffle list x in place; return None.

    Optional arg random is a 0-argument function returning a random
    float in [0.0, 1.0); by default, the standard random.random.
    """

    randbelow = self._randbelow
    for i in reversed(range(1, len(x))):
        # pick an element in x[:i+1] with which to exchange x[i]
        j = randbelow(i+1) if random is None else int(random() * (i+1))
        x[i], x[j] = x[j], x[i]
Run Code Online (Sandbox Code Playgroud)

When I run the shuffle function it raises the following …

python dictionary python-3.x

135
推荐指数
3
解决办法
11万
查看次数

标签 统计

dictionary ×1

python ×1

python-3.x ×1