allPrimes printing out a empty tuple Python
<p>So I have this code and it is supposed to print out a tuple with all the prime numbers in it. But instead, it's just printing out a empty tuple... </p>

<blockquote>
  <p>Can anyone tell me why?
  I also MUST USE A TUPLE.</p>
</blockquote>

<pre><code>def isPrime(number):
 for i in range(2,int(number**(0.5))+1):
     if number % i == 0:
         return False
     else:
         return True


def allPrimes(number):
    tup=()
    for i in range(1,number):
        if isPrime(i) == True:
            tup += (i,)
    print(tup)

allPrimes(26)
</code></pre>

<blockquote>
  <p>Here is the correct code</p>
</blockquote>

<pre><code>def isPrime(number):
    if number &lt; 2:
       return False
    for i in range(2, int(number ** (0.5)) + 1):
        if number % i == 0:
            return False
    return True



def allPrimes(number):
    tup=()
    for i in range(1,number):
        if isPrime(i) == True:
            tup += (i,)
        print(tup)

allPrimes(26)
out[1]: (2, 3, 5, 7, 11, 13, 17, 19, 23)
</code></pre>

<p>Because in the first iteration if <code>number % i != 0:</code> the number is prime, you have to return <code>True</code> at the end of the iteration an break it if `number % i == 0:  </p>

<pre><code>def isPrime(number):
    res = True
    if number &lt; 2:
        res = False
    else:
        for i in range(2,int(number**0.5)+1):
            if number % i == 0:
                res = False
                break
    return res
</code></pre>

python tuples primes