mercredi 9 décembre 2020

Get list from random list

Want to to a create a script that automate my weekly dinners and food shopping.

I can get it to print a random dish from a list. But i would also like to get it to print the ingrediens for randomly choosen dish to a shopping list.

How do o solve this?

from random import sample

## dishes

dishes = ["dish1","dish2"]

## recepies

dish1 = ["ingredient X", "ingredient Y"]
dish2 = ["ingredient Z"]

## random dish

food = sample.(dishes.1)

print ("random dish:", food)




Aucun commentaire:

Enregistrer un commentaire