Usually, zip
is the best way to solve your problem. But as it is a homework, and your teacher does not allow you to use zip
, I think you can take any solution from this page.
And I provide a version of using a lambda function. Note that if the length of both lists are not identical, a None
will be printed at the corresponding place.
>>> list_a = [1, 2, 3, 4, 5]
>>> list_b = ["red", "blue", "orange", "black", "grey"]
>>> for a,b in map(lambda a,b : (a,b), list_a, list_b):
... print a,b
...
1 red
2 blue
3 orange
4 black
5 grey