Using multiple variables in a for loop in Python

I am trying to get a deeper understanding to how for loops for different data types in Python. The simplest way of using a for loop an iterating over an array is as

for i in range(len(array)):
    do_something(array[i])

I also know that I can

for i in array:
    do_something(i)

What I would like to know is what this does

for i, j in range(len(array)):
    # What is i and j here?

or

for i, j in array:
    # What is i and j in this case?

And what happens if I try using this same idea with dictionaries or tuples?

Leave a Comment