Why doesn't random.choices work?

[4, 2, 1, 3]
0.7265755692280929
0.574565200183612
Traceback (most recent call last):
File “script.py”, line 16, in
print(random.choices(arr, k=3)) # [1, 1, 4]
AttributeError: module ‘random’ has no attribute ‘choices’

random.choice is not introduced until Python 3.6. You may be working with an older version (2.7, 3.5?)

randomer_number = random.choice(random_list)

Note there’s no “s” on .choice

1 Like

Copy that.

1 Like