What's the error in this code ... both test cases are failed

def p(n ):
for i in range(2,n):
if(n%i==0):
return False
return True
t = int(input())
for i in range(0,t):
st = input().split()
lo = int(st[0])
hi = int(st[1])
for i in range (lo , hi+1):
if p(int(i))== True:
print(i , end="\n")
print()

Hey,
Your code is taking too long to execute…
try to read about sieve of eratosthenes method and implement it.

Thanks,

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.