 <p>what I'd advice you would be to first remove all unnecessary data from the line, so you get exactly what you're looking for:</p> <pre><code>addr = [ x for x in line.split(" ") if x ][2] </code></pre> <p>and then printout that value along with the values in your list:</p> <pre><code>for target in mac_addr: print("'{}' vs '{}' -&gt; {}".format(addr, target, addr == target)) </code></pre> <p>so you can check how they differ.</p> <p>In the end:</p> <pre><code>with open('arp_table_output.txt','r+') as myArps: for line in myArps: # select *ONLY* the lines that contain the IP and MAC information in the input file if "Dynamic" in line: # here we extract the IP and the MAC from the line (python3 syntax) ip, _, mac, *_ = [ x for x in line.split(" ") if x ] # if you prefer python2: use `x, _, y, _, _, _ = …` # Test to printout what works and what does not. If none pass, the "in" test below will fail. for target in mac_addr: print("'{}' vs '{}' -&gt; {}".format(mac, target, mac == target)) if mac in mac_addr: ipaddr.append(ip) </code></pre>