Dec-27-2021, 03:43 AM
(This post was last modified: Dec-27-2021, 03:43 AM by noahverner1995.)
(Dec-26-2021, 12:37 PM)paul18fr Wrote: Maybe with:
import itertools as it the_dictionary_list = {'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo': ['Cuerpo_cangrejo.png'], 'Fondo': ['Oceano.png'], 'Ojos': ['Antenas.png', 'Pico.png', 'Verticales.png'], 'Pinzas': ['None', 'Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['None', 'Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']} AllKeysNames = the_dictionary_list.keys() Combinations = list(it.product(*(the_dictionary_list[Name] for Name in AllKeysNames))) print(f'{Combinations}')
Thanks for your reply!
I made a little improvement for my case, due to the need for grouping the elements in an specific order , here:
import itertools as it the_dictionary_list = {'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo': ['Cuerpo_cangrejo.png'], 'Fondo': ['Oceano.png'], 'Ojos': ['Antenas.png', 'Pico.png', 'Verticales.png'], 'Pinzas': ['None', 'Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['None', 'Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']} AllKeysNames = ['Fondo', 'Cuerpo', 'Ojos', 'Color', 'Pinzas', 'Puas'] Combinations = list(it.product(*(the_dictionary_list[Name] for Name in AllKeysNames))) print(f'{Combinations}')