cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
227
Views
0
Helpful
0
Replies

Python List and For Loop

Netmart
Level 1
Level 1

Hello,

For some the if statement is not hit and only the last print statement [number of iterations is shown.

The intention is what elements of List-ACI-nodes are not part of List-vrf-nodes:

 

file=open ("List-vrf-nodes.txt")
count=0
testList=[]
for line in file:
     #rstrip to remove "\n"
     testList.append(line.rstrip())

file2=open ("List-ACI-nodes.txt")
for keyword in file2:
     count=count+1
     print(keyword)
     print ("list:",str(testList))
     if (keyword in testList
       print (keyword, " in list")
       
     else:
       (keyword, " not in list")

print ("count:",count)    
0 Replies 0