Question: 1 . Convert the string to a list. 2 . Create a loop through the list 3 . for each line in the list add

1. Convert the string to a list.
2. Create a loop through the list
3. for each line in the list add the text 'line ' followed by line number
4. print each line using string concatenation
lldp ='''*A:STTLWAGANGB06# show system lldp neighbor
Link Layer Discovery Protocol (LLDP) System Information
===============================================================================
NB = nearest-bridge NTPMR = nearest-non-tpmr NC = nearest-customer
===============================================================================
Lcl Port Scope Remote Chassis ID Index Remote Port Remote Sys Name
-------------------------------------------------------------------------------
1/1/c8/1NB FC:96:43:4A:12:414et-9/2/1TAMPFLXE-MSE02-*
1/1/c21/1 NB FC:96:43:49:71:4144100GbE to STTL* DLLSTX16-MSE148*
1/1/c3/1NB 9E:92:75:00:06:0846 HundredGigE0/4* STTLWAGA-MSE05-*
===============================================================================
* indicates that the corresponding row element may have been truncated.
Number of neighbors : 3
*A:STTLWAGANGB06#'''
Exercise 2
1. Convert the string to a list.
2. Slice the list to include only the lines that contain LLDP neighbor data (3 lines, only the data within the table)
3. Print the list using a loop
lldp ='''*A:STTLWAGANGB06# show system lldp neighbor
Link Layer Discovery Protocol (LLDP) System Information
===============================================================================
NB = nearest-bridge NTPMR = nearest-non-tpmr NC = nearest-customer
===============================================================================
Lcl Port Scope Remote Chassis ID Index Remote Port Remote Sys Name
-------------------------------------------------------------------------------
1/1/c8/1NB FC:96:43:4A:12:414et-9/2/1TAMPFLXE-MSE02-*
1/1/c21/1 NB FC:96:43:49:71:4144100GbE to STTL* DLLSTX16-MSE148*
1/1/c3/1NB 9E:92:75:00:06:0846 HundredGigE0/4* STTLWAGA-MSE05-*
===============================================================================
* indicates that the corresponding row element may have been truncated.
Number of neighbors : 3
*A:STTLWAGANGB06#'''
PreviousNext

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!