How to Get 10 Random Numbers in Python
The random
module allows you to generate choices
.
This might give us back something like:
[635, 450, 26, 829, 786, 563, 294, 586, 893, 953]
Explaining random.choice
and random.choices
random.choice
takes a sequence
as a parameter and return a single random item from it.
While random.choices
takes a sequence as a parameter and returns a few random items from it. You can specify how many random items to return by populating the k=
parameter, as above.