Say, I have two lists a
and b
:
a = [10, 20]
b = [40, 50]
I want to loop over all these values (10, 20, 40, 50
) in one go.
Simply doing two loops is not what I want (repetition is ugly).
I also don't want to modify one of the lists:
a.extend(b)
for i in a:
print(i)
So how do I do this elgantly in Python?