Files
2024-05-29 10:06:17 -07:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
65b7cd2b7bd9a684ccf1dc16 Крок 9 20 step-9

--description--

Щоб ітерувати над ключами словника, можна просто додати словник до циклу for. Код нижче надрукує всі ключі зі словника dict:

for i in dict:
   print(i)

Замініть виклик print() на цикл for, який ітерує над copper та надрукує всі ключі.

--hints--

Код не повинен містити print(copper).

({ test: () => assert.isFalse(runPython(`_Node(_code).has_call("print(copper)")`)) })

Створіть цикл for, щоб ітерувати над словником copper.

({ test: () => assert(runPython(`_Node(_code).find_for_loops()[0].find_for_iter().is_equivalent("copper")`)) })

Надрукуйте всі ключі copper в межах циклу 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'

print(copper)
--fcc-editable-region--