Back to Freecodecamp

Step 4

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

latest966 B
Original Source

--description--

You can access the data stored in a dictionary through its keys:

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

my_dict['name'] # 'Michael'

After your dictionary, follow the example above to access the 'species' key of copper and print the result.

--hints--

You should not modify the assignment of your dictionary.

js
({ test: () => assert(runPython(`
    copper == {"species": "guinea pig", "age": 2}
  `))
})

You should use copper['species'] to access the value of the 'species' key.

js
({ test: () => assert.match(code, /copper\s*\[\s*("|')species\1\s*\]/) })

You should call print() passing copper['species'] as argument.

js
({ test: () => assert.match(code, /^print\s*\(\s*copper\s*\[\s*("|')species\1\s*\]\s*\)/m) })

--seed--

--seed-contents--

py
--fcc-editable-region--
copper = {
    'species': 'guinea pig',
    'age': 2
}

--fcc-editable-region--