⚑ IT Wisdom Why did the packet get dropped? It had low TTL β€” relatable honestly.
Skilled Practitioner
4249 XP 1751 to Expert
Objective: Use a for loop with continue to process only online devices.
Instructions

Create a file called lab2.py. Write a script using the device list below. Loop through every device. If a device is offline (online: False), skip it using continue. For every online device, print Processing: <name>.

devices = [
    {"name": "sw-core-01", "online": True},
    {"name": "sw-access-01", "online": False},
    {"name": "rtr-edge-01", "online": True},
    {"name": "sw-access-02", "online": False},
]

Run it with python3 lab2.py. Paste your output below and submit.

Starter Code
devices = [
    {"name": "sw-core-01", "online": True},
    {"name": "sw-access-01", "online": False},
    {"name": "rtr-edge-01", "online": True},
    {"name": "sw-access-02", "online": False},
]

for device in devices:
    if not device["online"]:
        continue
    print(f"Processing: {device['name']}")
πŸ’‘ Show Hint
Use "if not device["online"]: continue" to skip offline devices. The continue statement jumps straight to the next iteration without running the print line.
Paste Your Output
Next Lab β†’