Free lab Real Python 3. Zero installs. Your code stays in this browser. Open the playground

Two Sum

Medium · 60 XP

Given a list and a target, return the indices of the two numbers summing to it — in one pass, not nested loops. Print the result for three cases.

Target output
[0, 1]
[1, 2]
[]
Blank · autosaved
PYtwo-sum.py
Run your code to check it…
Your next ten minutes

Write Python that does something useful.

Start free. No install, no card, no passive video marathon.

Start learning free → Explore the path