Skip to content
Advertisement

How do I iterate over two lists?

I have troubles in using for loops in Python. I wrote this code:

JavaScript

and the output is:

JavaScript

But I would like the output to be:

JavaScript

Is there a way to make the for loop iterate over first “Mary” and “she” and then “Joe” and “he” ?

I thank you in advance.

Advertisement

Answer

Why, you can go with zip(). Here is a cleaner solution.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement