While loop only responding to second condition
<p>My while loop is only ending when it matches the second condition, the first one is being ignored, I have no idea what I am doing wrong</p>

<pre><code>while (response !=0) or (cont != 5):
    response = os.system("ping -c 2 " + hostname)
    cont=cont+1
    print cont
    print response
</code></pre>

<p>With <code>subprocess.call</code>:</p>

<pre><code>import subprocess

for count in range(5);
    response = subprocess.call(["ping", "-c", "2", hostname])
    if not response:
        break
</code></pre>

<p>Prefer an iteration with <code>range</code> or <code>xrange</code>.</p>

python