mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-12 01:00:13 -04:00
1.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 65b7d3319ebec69b983fb91b | Крок 12 | 20 | step-12 |
--description--
Як можна побачити з виводу, .items() створює структури даних, які зберігають пари ключ-значення в окремих кортежах. Щоб ітерувати над елементами в цих кортежах, ви можете додати другу змінну циклу:
for i, j in dict.items():
print(i, j)
Змініть цикл for, щоб він приймав дві змінні циклу та надрукував їх в межах тіла циклу.
--hints--
Змініть цикл for, щоб він використовував дві змінні.
({ test: () => assert(runPython(`
import ast
var = _Node(_code).find_for_loops()[0].find_for_vars()
isinstance(var.tree, ast.Tuple)
`)) })
Надрукуйте обидві змінні циклу в межах циклу for.
({ 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--