title: How to get scapy IP address list result from sr function into a variable
body: <p>I am trying to do an ICMP (host is alive scan) in a range of ip addresses with the use of scapy.
  But i want to store the result list from the sr function( only the answers ) at a variable so that i can use it for some other purpose. But it does not seem to work.
  <strong>I tried  <a href="https://stackoverflow.com/questions/10371310/getting-variables-from-scapy-using-python">this</a> but it does not work in my case, cause the expected result is a list of IP's and i want to store and display later all of them.</strong></p>
  
  <p>If i enter scapy and type the above commands it works fine!</p>
  
  <pre><code>ans,_ = sr(IP(dst='192.168.1.1-7')/ICMP(), timeout=10)
  ans.summary( lambda s_r: s_r[1].sprintf("{IP: %IP.src% is alive}"))
  </code></pre>
  
  <p>The result that gives me :</p>
  
  <pre><code> 192.168.1.1 is alive
   192.168.1.3 is alive
   192.168.1.5 is alive
   192.168.1.6 is alive
  </code></pre>
  
  <p>This is what i tried(in my pycharm project) but it gives the error <strong>'tuple' object has no attribute 'getlayer'</strong></p>
  
  <pre><code>ips = '192.168.1.1-9'
  ans, _ = sr(IP(dst=ips) / ICMP(), timeout=10)
  address = ans.getlayer(IP).src
  print(address)
  </code></pre>