Zip Two Lists Into Pairs

Easy ⏱ 8 min 89% acceptance ★★★★☆ 4.3
Write a function pair_names_scores(names, scores) that returns a list of strings like "name: score" by iterating over both lists together with zip(). If the lists differ in length, stop at the shorter one (default zip behavior).

Examples

Example 1
Input
pair_names_scores(["Amy", "Bo"], [90, 85])
Output
["Amy: 90", "Bo: 85"]
Explanation

Elements paired positionally.

Constraints

  • names and scores are lists.

Topics

Loopszip()

Companies

AppleCisco

Hints

Hint 1

`for name, score in zip(names, scores):` pairs elements from both lists.

Hint 2

Format each pair with an f-string and collect into a list.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.