I'm struggling with this code not outputing what I'm expecting.
Here the code:
'base' is a list of sets
'items' is a list of str
base = [{'🌭', '🍔'},{'🌭', '🍕'},{'🌮', '🍔'},{'🌮', '🍕'},{'🍆', '🍑'}]
items = ['🌭','🍔','🍕','🌮','🍆','🍑']
for i in items:
for j in base:
j.add(i)
My result is this if I print base
[{'🌭', '🌮', '🍆', '🍑', '🍔', '🍕'},
{'🌭', '🌮', '🍆', '🍑', '🍔', '🍕'},
{'🌭', '🌮', '🍆', '🍑', '🍔', '🍕'},
{'🌭', '🌮', '🍆', '🍑', '🍔', '🍕'},
{'🌭', '🌮', '🍆', '🍑', '🍔', '🍕'}]
But I'm looking to have something like this, where every item on items gets added to every set in base.
[{'🌭', '🌭', '🍔'},
{'🍔', '🌭', '🍔'},
{'🍕', '🌭', '🍔'},
{'🌮', '🌭', '🍔'},
{'🍆', '🌭', '🍔'},
{'🍑', '🌭', '🍔'},
{'🌭', '🌭', '🍕'},
{'🍔', '🌭', '🍕'},
{'🍕', '🌭', '🍕'},
{'🌮', '🌭', '🍕'},
{'🍆', '🌭', '🍕'},
{'🍑', '🌭', '🍕'},
...]
baseto List of lists