mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-11 16:00:12 -04:00
1.2 KiB
1.2 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 65b7d3319ebec69b983fb91b | Step 12 | 20 | step-12 |
--description--
As you can see from the output, .items() creates a data structures that stores each key-value pair in a distinct tuple. To iterate over the elements in those tuples you can add a second loop variable:
for i, j in dict.items():
print(i, j)
Modify your for loop to take two loop variables and print both of them inside the loop body.
--hints--
You should modify your for loop to use two variables.
({ test: () => assert(runPython(`
import ast
var = _Node(_code).find_for_loops()[0].find_for_vars()
isinstance(var.tree, ast.Tuple)
`)) })
You should print both loop variables inside your for loop.
({ test: () => assert(runPython(`
var = _Node(_code).find_for_loops()[0].find_for_vars()
_Node(_code).find_for_loops()[0].find_bodies()[0].is_equivalent(f"print{var}")
`)) })
--seed--
--seed-contents--
--fcc-editable-region--
copper = {
'species': 'guinea pig',
'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'
for i in copper.items():
print(i)
--fcc-editable-region--