Python for developers paractice problems

Suggestion for reducing execution time on this solution.
def pr(m,l,n):
prime = [True for i in range(l+2)]
p = 2
while (p * p <= l):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
for p in range(2, n):
if (p>=m and p<=l and prime[p]==True):
print(p,end=" ")

t=int(input())
while t>=1:
m, n=map(int,input().split( ))
pr(m,n,n-m)
print()
t=t-1

I would suggest that you look into the concept of Sieves of Eratosthenes , it is one of the best algorithms made to find out primes.
If you want then you can also check the free trial part of the online course - Algo++ ,which contains a couple of videos on this.

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.