I am fairly very new to Python or any programming language for that matter. I am finding it challenging to print arbitrary text along with with iterated values from a list, using for loop. What I need is to print the whole first item of the list with arbitrary text "shutdown" and repeat the same for new text "no shutdown". Also, I want to be able to insert any text statements between the two separate outputs: Please advise. Here is more information..
CURRENT OUTPUT: Which is not desired
interface Vlan100
shut
no shut
interface Vlan108
shut
no shut
EXPECTED OUTPUTS:
# First time printing:
********* THIS IS INTERFACE OUTPUT WITH "SHUTDOWN" **********
interface Vlan100
shutdown
interface Vlan108
shutdown
** THIS IS INTERFACE OUTPUT WITH "NO SHUTDOWN" ***
*# Second time printing:*
interface Vlan100
no shutdown
interface Vlan108
no shutdown
CODE EXTRACT, Snipped for brevity reasons.
for i in servicetypes:
<snip>
<snip>
elif "ipv4 address" in i or "ipv4 address 8" in i or " ipv4 address 213" in i:
i = re.sub(r'encapsulation dot1Q \d+\n\s','',i)
i = re.sub(r'TenGigE[0-9]/[0-9]/[0-9]/[0-9].','Vlan',i)
internet = i.split("\n")
print internet[1]
print " shut"
print " no shut"
101010button for formatting."ipv4 address" in i or "ipv4 address 8" in i or " ipv4 address 213" in iis kind of redundant, assumingiis a string.