I have a simple array that I have to pick one or more unique values
from and am kind of stumped as to how to do this. Here’s the what the
array looks like:
foo = [2, 7, 10, 14] # (or could equal a diff’t set of 4
Now for this task, I’m not interested in the first element at all.
I’d rather just leave it alone and not delete it though.
What I need to do is pick 1 to 3 elements randomly from the array. I
can’t reuse the numbers.
So, for example, if I need 1 number then it could be any of the
elements 1-3 from the array.
If I need 2 numbers, it could be any of elements 1-3 but I can’t pick
the same number twice. Ditto for when I need 3 numbers.
I don’t need the numbers in any particular order, so I’m just looking
for the simplest loop/function to pick the unique numbers for me.
Any suggestions? Thanks.