Files
2024-05-22 17:27:37 +02:00

1.2 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6579717f0920131304286804 Schritt 6 20 step-6

--description--

To add a new key-value pair after declaring a dictionary, you can indicate the key in the same way you would access an existing key, and set the value of the new key by using the assignment operator:

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

my_dict['country'] = 'Canada'

Delete your print() call. Then, after the copper declaration, add the key 'food' to your dictionary and set its value to 'hay'.

--hints--

You should not have print(copper['age']) in your code.

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

You should add the key 'food' to copper after declaring the dictionary.

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

You should set copper['food'] to 'hay' after declaring the dictionary.

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

--seed--

--seed-contents--

--fcc-editable-region--
copper = {
    'species': 'guinea pig',
    'age': 2
}
print(copper['age'])
--fcc-editable-region--