# Get A Random Set Of Items From From List

Use [TODO: Code shorthand span ] to get random items from a list without repeating any

```
=
```

#+OLDNOTES :

import random

# Note that .choices can return the same thing multiple times. # This means it can duplicate. It also means, you can ask for # more items than are in the list.

# .sample() is "without replacement" so each item can be chosen # only one time. If the list is smaller than the requested number # of items (via ` k ` ) then the script goes boom.

def get _ up _ to _ n _ random _ items _ from _ list(source _ list, requested _ number _ of _ items _ to _ get) : items _ to _ get = min(requested _ number _ of _ items _ to _ get, len(source _ list)) return _ list = random.sample(source _ list, k=items _ to _ get)

return return _ list

input _ list = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC']

print( get _ up _ to _ n _ random _ items _ from _ list(input _ list, 5) )