QuestionQ482

Automation

An engineer implements a Python script in a Cisco Bash shell. The script contains this dictionary object:

Question Image

Which command must be used to add the 'N9K-Spine-2': '1498323434' element to the switch_id list dictionary?

  • A switch_id_list += {ג€N9K-Spine-2ג€: ג€1498323434ג€}
  • B switch_id_list = [ג€N9K-Spine-2ג€: ג€1498323434ג€]
  • C switch_id_list.append({ג€N9K-Spine-2ג€: ג€1498323434ג€})
  • D switch_id_list.update({ג€N9K-Spine-2ג€: ג€1498323434ג€})
Explanation

Python dictionaries are mutable mappings, and dict.update() adds the key/value pairs from another mapping to the existing dictionary. The supplied one-entry dictionary therefore inserts the N9K-Spine-2 key with its associated value.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!