← All Exercises

Python Loop Patterns

basicpython~10min

Background

Python offers powerful iteration patterns like enumerate and zip that eliminate manual index tracking.

Problem

Write a function that takes two lists of equal length and returns a list of formatted strings pairing elements with their index.

Input

Two lists of equal length containing strings.

Output

A list of formatted strings like "0: a-b" pairing elements by index.

Sample tests

Sample 1

Input: ["a","b"], ["x","y"]
Expected: ["0: a-x", "1: b-y"]

Your solution

Learning objective

Learn Pythonic iteration with enumerate, zip, and tuple unpacking in comprehensions.