Prime Generator in Python

The compiler keeps throwing an error, whereas the code seems to work fine in other IDEs.

Here’s the code:
testcases = int(input())

while(testcases!=0):

lower_limit = int(input())
upper_limit = int(input())

i, j, flag = 0, 0, 0

for i in range(lower_limit, upper_limit+1):
	if(i==1):
		continue
	flag = 1

	for j in range(2, i//2 + 1):
		if(i%j==0):
			flag = 0
			break
	
	if(flag==1):
		print(i, end=" ")

print("\n")
testcases -= 1

Hey @developerkushal, while you are running your code on ide you need to first provide the custom input. Press the input button on top right near run and than provide the sample input and than click on run button.

Hope this cleared your doubt. :blush:

Also change the following two lines,
lower_limit = int(input())
upper_limit = int(input())

to

temp = input().split()
lower_limit = int(temp[0])
upper_limit = int(temp[1])

Hope this cleared your doubt. :sunny:

It keeps giving this error now:

Traceback (most recent call last):
File “source”, line 1, in
testcases = int(input())
EOFError: EOF when reading a line

When you are running code on ide you need to provide the custom input first. Click on input button and than provide the input and than press the run button.

Hope this cleared your doubt. :blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.