Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Pair Elements With Zip

Combine two sequences element-wise into pairs using zip.

Python practice7 minLoops & IterationBeginnerLast updated March 15, 2026

Problem statement

Given two iterables a and b, return a list of tuples where each tuple contains the i-th element from a paired with the i-th element from b. If the iterables have different lengths, stop at the shorter one (behavior of zip).

Task

Use zip to pair corresponding elements from two iterables into a list of tuples.

Examples

Numbers pairing

Input

pair_elements([1,2], [3,4])

Output

[(1, 3), (2, 4)]

Elements at matching positions are paired.

Input format

Two iterables: pair_elements(a, b)

Output format

A list of tuples: [(a0, b0), (a1, b1), ...]

Constraints

- Iterables may be of different lengths; pair only up to the shorter one. - Iterables may contain any types. - Do not assume inputs are lists (strings and other iterables should work).

Samples

Sample 1

Input

pair_elements([1,2,3], [4,5])

Output

[(1, 4), (2, 5)]

Stops when the second iterable is exhausted.