fork download
  1. items = [
  2. ['Te1/1/1', 'server', 'Ten', 'connected', 'trunk', 'full', '10G', '10Gbase-LR'],
  3. ['Te1/1/2', 'desc', 'connected', 'trunk', 'full', '10G', '10Gbase-LR'],
  4. ['Gi1/2/1', 'desc', 'disabled', 'routed', 'full', '1000', 'No', 'Transceiver'],
  5. ['Gi2/1/2', 'disabled', 'routed', 'full', '1000', 'No', 'Transceiver'],
  6. ['Te2/2/1', 'server', 'notconnect', '301', 'full', '10G', '10Gbase-LR'],
  7. ['Po120', 'notconnect', 'unassigned', 'auto', 'auto'],
  8. ['Po121', 'notconnect', '1', 'auto', 'auto']
  9. ]
  10.  
  11. for item in items:
  12. for i in item[1:]:
  13. if not i.startswith(("notconnect", "connected", "disabled")):
  14. item.remove(i)
  15. continue
  16. break
  17. print(item)
Success #stdin #stdout 0.02s 9088KB
stdin
Standard input is empty
stdout
['Te1/1/1', 'connected', 'trunk', 'full', '10G', '10Gbase-LR']
['Te1/1/2', 'connected', 'trunk', 'full', '10G', '10Gbase-LR']
['Gi1/2/1', 'disabled', 'routed', 'full', '1000', 'No', 'Transceiver']
['Gi2/1/2', 'disabled', 'routed', 'full', '1000', 'No', 'Transceiver']
['Te2/2/1', 'notconnect', '301', 'full', '10G', '10Gbase-LR']
['Po120', 'notconnect', 'unassigned', 'auto', 'auto']
['Po121', 'notconnect', '1', 'auto', 'auto']