Question 500
A Python script loops through device addresses but stops after the first because return is inside the loop. What is the best implementation or corrective action?
Explanation
Correct Answer
A return exits the function immediately and can prematurely terminate iteration. A direct operational check is: All devices produce results before the function returns its collection.
Incorrect Answers
That action addresses a different condition: a script iterates over a string of addresses and inadvertently processes each character as a separate host. Iterating a string yields characters, while iterating a list yields its elements.
That action addresses a different condition: an exception from one unreachable router stops collection from every other router. Localized error handling permits processing remaining devices without hiding the error.
That action addresses a different condition: a Python function called parse_routes prints a route but the caller receives None and cannot test it. print displays output but does not return a value to the caller.