You can use the shuffle() method in the list before the slice.
If the order of the list matters, just make a copy of it and cut it out of the copy.
mylist
As above, you can also use len () instead of specifying the length of the list.
hit>
As shown below in THC4K, you can use the random.sample () method, for example below IF , which you need is a set of random numbers from the list (this is how I read your question).
mylist
This is much more complicated than my first attempt!
Azz source share