I am wondering if it's posiible to iterate over two lists at once.
Something like that:
for x, m in list1, list2:
...
I know that I should use the '.items()', but I don't want to create dictionary from two lists.
Any ideas?
I am wondering if it's posiible to iterate over two lists at once.
Something like that:
for x, m in list1, list2:
...
I know that I should use the '.items()', but I don't want to create dictionary from two lists.
Any ideas?
Use zip.
for x, m in zip(list1, list2):
zip(*iterables)
Make an iterator that aggregates elements from each of the iterables.
Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The iterator stops when the shortest input iterable is exhausted. With a single iterable argument, it returns an iterator of 1-tuples. With no arguments, it returns an empty iterator.