You'd have to collect all the various key elements into lists, then loop over those (using itertools.product()
, preferably). The collecting can be done with zip()
:
from itertools import product
gene_regions, species_plural, ontologies, lengths = zip(*result_dict)
for gene_region, species, ontology, length in product(gene_regions, species_plural, ontologies, lengths):
# do something with this combo.
product()
produces the same sequence of combinations as if you had nested your loops.