Files

1.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
65b7cd2b7bd9a684ccf1dc16 Step 9 20 step-9

--description--

To iterate over the keys of a dictionary, you can simply put the dictionary into a for loop. The code below would print each key in the dictionary dict:

for i in dict:
   print(i)

Replace the print() call with a for loop that iterates over copper and prints each key.

--hints--

You should not have print(copper) in your code.

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

You should create a for loop to iterate over the copper dictionary.

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

You should print each key of the copper 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'

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