Back to Freecodecamp

Step 13

curriculum/challenges/english/blocks/learn-algorithm-design-by-building-a-shortest-path-algorithm/6579cbab9825b8170974c69a.md

latest758 B
Original Source

--description--

You can remove a key-value pair from a dictionary by using the del keyword:

py
my_dict = {
    'name': 'Michael',
    'occupation': 'Lumberjack'
}

del my_dict['occupation']

Just before your for loop, use the del keyword to delete the 'age' key and its value from copper.

--hints--

You should use the del keyword to delete copper['age'] before the for loop.

js
({ test: () => assert.match(code, /^del\s+copper\s*\[\s*("|')age\1\s*\].*^for\s*/ms) })

--seed--

--seed-contents--

py
--fcc-editable-region--
copper = {
    'species': 'guinea pig',
    'age': 2
}
copper['food'] = 'hay'
copper['species'] = 'Cavia porcellus'

for i, j in copper.items():
    print(i, j)
--fcc-editable-region--