title: Return a ping test result in Python
body: <p>I'm trying to print results from a ping test on Windows. However, when the website times out the following error occurs: </p>
  
  <p>IndexError: list index out of range. </p>
  
  <p>Obviously, it's looking for the results but how can I make it say "Website not available" when it does time out? </p>
  
  <pre><code>try:
      ping = subprocess.Popen(["ping", "-n", "5", website], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      out, error = ping.communicate()
  
      minimum = int(re.findall(r"Minimum = (\d+)", out)[0])
      maximum = int(re.findall(r"Maximum = (\d+)", out)[0])
      average = int(re.findall(r"Average = (\d+)", out)[0])
      packet = int(re.findall(r"Lost = (\d+)", out)[0])
  
      if packet &gt; 1:
          packet = 5 / packet * 100
  
      except subprocess.CalledProcessError:
          print "Couldn't get a ping"
  </code></pre>