I want to be able to iterate over a list with named lists inside
I tried doing this:
Objects = {
"Enemies":[
"Enemy1",
"Enemy2",
"Enemy3"
],
"Walls":[
"Wall1",
"Wall2",
"Wall3"
]
}
for Type in Objects:
for Object in Type:
print(Object)
But this doesn’t work and prints the letters of the Types under each other
>Solution :
for Type in Objects loops over the keys of the dictionary. You want to loop over the values.
for v in Objects.values():
for name in v:
print(name)