0

I’m coding a discord bot in discord.py and I want people to be able to retrieve multiple different random values from a list. Here’s an example

list = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]

@client.command
async def pick(ctx, amount):
    await ctx.send(f’{random.choice(list)}’)

I’m getting stuck here. Any help is appreciated.

1 Answers1

1

Python provides random.sample() which does exactly what you want.

random.sample(population, k)

Return a k length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173