python simple basic program on geeksforgeeks
<p>Can anyone help me with the solution of this ?</p>

<p>Given a number N, print all the composite numbers less than or equal to N. The number should be printed in ascending order.</p>

<p>Input:
The first line contain an Integer T denoting the number of  test cases . Then T test cases follow. Each test case consist of an single integer N.</p>

<p>Output:
Print all the composite Number form 0 to N.</p>

<p>Constraints:</p>

<pre><code>1 â¤ T â¤ 50
4 â¤ N â¤ 10000

Example:
Input:
2
10
6
Output:
4 6 8 9 10
4 6
</code></pre>

<p>My solution is as below :</p>

<pre><code>def comp(n):
    for i in range (4,n+1):
        for j in range(2,i):
            if i % j == 0 :
                print(i)
                break

t = int(input(""))

while(t &gt;=1 &amp; t &lt;= 50):
        for k in range(0,t):
            p = int(input(""))
            if(p &gt;=4 &amp; p &lt;= 10000):
                comp(p)
</code></pre>

<p>but giving <code>EOFError</code> on <code>p = int(input(""))</code></p>

<p>The culprit here is the <code>while</code> loop instead of <code>if</code>. As, the <code>t</code> is a constant value, the <code>while</code> loop will never end and thus, <code>p = int(input(""))</code> will get executed more than the required times. Hence, <code>EOFError</code> on <code>p = int(input(""))</code>.</p>

python