I am looking for a more pythonic way to loop though a list starting an an index then return the values contained in sub-lists eg:
values = [[1,2], [2], [1,3,4]]
n=1
for i, item in enumerate(values[n:]):
i += n
if i < len(values):
for sub_value in values[i]:
print("index: "+str(i)+ " list: "+str(item)+ " sub value: "+str(sub_value))
The code works as intended but is pretty ugly, any ideas to simplify it?
i += n?oop though a list starting an an index then return the values contained in sub-listsThis contradicts with your programindex: 1 list: [2] sub value: 2 index: 2 list: [1, 3, 4] sub value: 1 index: 2 list: [1, 3, 4] sub value: 3 index: 2 list: [1, 3, 4] sub value: 4