How to select *multiple* random items from a JSON list

I’m trying to generate a “cooking challenge” – based on a list of ingredients in season, I want to randomly select three, add them to my shopping basket and figure out a meal.

I’ve created a list of food in season, which changes monthly:

{% set ingredients_list = ['Aubergine', 'Beetroot', 'Broccoli', 'Brussels Sprouts', 'Butternut Squash', 'Carrots', 'Cauliflower', 'Celery', 'Courgettes', 'Chicory', 'Chillies', 'Cucumber', 'Garlic', 'Kale', 'Kohlrabi', 'Leeks', 'Lettuce', 'Mangetout', 'Marrow', 'Onions', 'Parsnips', 'Peas', 'Peppers', 'Potatoes', 'Pumpkin', 'Radishes', 'Rocket', 'Runner Beans', 'Samphire', 'Sorrel', 'Spinach', 'Spring Greens', 'Spring Onions', 'Summer Squash', 'Sweetcorn', 'Swiss Chard', 'Tomatoes', 'Turnips', 'Watercress', 'Wild Mushrooms', 'Beef', 'Duck', 'Turkey', 'Lamb', 'Game. Clams', 'Hake', 'Mussells', 'Blackberries', 'Damsons', 'Pears', 'Plums', 'Raspberries', 'Rhubarb', 'Strawberries'] %}

I know I can grab a random one of these with {{ ingredients | random }}, but how would I create a list of three random ingredients? EDIT: I figured this out as I was typing the question, the key is in storing the list as an intermediate variable and generating multiple randoms. Leaving this here in case anyone is trying to do the same.

For example:

{{ ingredients_list | random }}, {{ ingredients_list | random }}, {{ ingredients_list | random }}

(yes, there’s a chance that the same ingredient will be selected multiple times but I can live with that)

Replying to myself so I can mark that the question contains the solution!

If you use the shuffle filter then index slice, you avoid the possibility of duplicates:

{{ (ingredients_list|shuffle)[:3] }}

I guess if you wanted to, you could “double” the randomness by randomizing where the slice starts…

{% set x = range(0,ingredients_list|count-3)|random %}
{{ (ingredients_list|shuffle)[x:x+3] }}