I would like to know how i can iterate through a list containing lists in python, however i would like to use the for loop method that uses index rather than iterating the normal way in python. is it possible to do that?
here is the python code:
n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
def flatten(my_lists):
results = []
for outer in range(len(my_lists)):
for inner in range(len(outer)):
results.append(lists[outer][inner])
return results
print flatten(n)
this is the error I get in the console:
Traceback (most recent call last):
File "python", line 10, in <module>
File "python", line 6, in flatten
TypeError: object of type 'int' has no len()
what is the error in my code ?
thanks in advance.