An engineer implements a Python script inside a Cisco Bash shell. The script contains this dictionary object: 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ג€})
not append(), update() method is correct!
switch_id_list = {
"N9K-SPINE-1" : "0000",
"N9K-LEAF-1" : "1111",
"N9K-LEAF-2" : "2222"
}
switch_id_list.update({"N9K-Spine-2" : "3333"})
print(switch_id_list)
===============================================
{'N9K-SPINE-1': '0000', 'N9K-LEAF-1': '1111', 'N9K-LEAF-2': '2222', 'N9K-Spine-2': '3333'}
this switch_id_list type is "dict" not "list" ( plz using type() func! )
if it's type was "list" that append() method might be correct.
Option D is incorrect because the "update" method is used to update an existing key-value pair in a dictionary, not to add a new element to a list of dictionaries.
Totally agree with rocky
'dict' object has no attribute 'append' in Python
upvoted 4 times
...
This section is not available anymore. Please use the main Exam Page.350-601 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
roky
Highly Voted 2 years, 1 month agoPacketLife
Most Recent 1 year, 9 months agoredgremlin
1 year, 6 months agoCoAsT_x
5 months, 2 weeks agoHsma
2 years agoGuyThatTakesDumps
2 years, 1 month ago7korn7
2 years, 1 month ago