Dec-04-2018, 04:16 PM
It's not clear what you're trying to do. Could you show some code, along with what the output is vs your expected output?
If it's just iterating over a list of lists, then a for loop works fine:
If it's just iterating over a list of lists, then a for loop works fine:
>>> fruit = ["spam", "eggs", "ham"] >>> veggies = ["gross", "green", "not-chocolate"] >>> consumables = [fruit, veggies] >>> for sublist in consumables: ... for item in sublist: ... print(item) ... spam eggs ham gross green not-chocolate