We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Zip

The zip function takes two iterables (often lists), and returns a new iterable where each element is a tuple containing one element from each of the original iterables.

a: list[int] = [1, 2, 3]
b: list[int] = [4, 5, 6]

c: list[tuple[int, int]] = list(zip(a, b))
print(c)
# [(1, 4), (2, 5), (3, 6)]

Assignment

Complete the pair_document_with_format function. It takes two lists of strings as input:

  • doc_names: the names of documents
  • doc_formats: the file formats of the documents