Automation and Artificial Intelligence
What does this Python code print? interfaces = ["Gi0/0", "Gi0/1", "Gi0/2"] print(interfaces[1])
Show the answer
Correct answerA. Gi0/1
AWhy this is right: Index 1 retrieves the second element of the list, Gi0/1.
BWhy not this: Index 1 is valid because the list contains three elements.
CWhy not this: Gi0/2 is at index 2, not index 1.
DWhy not this: Gi0/0 is at index 0; treating index 1 as the first element assumes one-based indexing.
Python lists use zero-based indexing, so index 1 retrieves the second element, Gi0/1. Gi0/0 is at index 0, not index 1.