When will python while loop break?
<p>I'm new to python or coding in general. And encountered some while loop question in the following code.</p>

<hr>

<pre><code>a = int(input('input a number here: '))

def largest_factor(x):   
    factor = x - 1
    while factor &gt; 0:
        if x % factor == 0:
             return factor
        factor -= 1
        print(factor)

largest_factor(a)
</code></pre>

<hr>

<p>I'm using python 3.5, and in my understanding, the loop will not break until 0 > 0, so I put the print(factor) to exam that, however, it stopped at the largest factor(e.g. when x = 100, factor prints from 99 all the way to 50, and stopped), and did not reach 0. Is the return statement killed the while loop? Thank you for your time.</p>

<p>There are two ways to leave this loop, waiting until the while statement terminates or by returning the factor.</p>

python python-3.x