Source code
for x in []: print(x)
❯ Try editing the highlighted part of the code above
Edit the [ … ] in the code above (e.g. 1, 2, 3, 4). Changing the items changes how many times next runs — and which element gets skipped at the end.
Memory / executionStep 1 / 5
👁 What you can see ── for pulls them out one at a time
for x in [10, 20, 30]: puts the list’s contents into x one at a time and prints each. The output, top to bottom, is 10, 20, 30. It’s a familiar shape ── nothing mysterious. ── But how does Python actually “take them out one at a time” inside? Use ▶ to peek step by step. At the end, a “trap” shows up that bites if you don’t know the mechanism.
Details
1 / 1