Multiple lists

It’s also common to need to iterate over two lists at once. This is where the built-in zip function comes in handy.

zip will create pairs of elements when passed two lists, and will stop at the end of the shorter list.

zip can handle three or more lists as well!



Compare each pair of elements and print the larger of the two.

Folder Icon

Take this course for free

Already have an account?