Prime generator: this code exceeds the time limit and so the test cases do not pass. how can i decrease it's time complexity?

t=input()
print("\n")
flag=1;
if t<=10:
for i in range(0,t):
m,n=raw_input().split(" “)
m= int(m)
n= int(n)
if m>=1 and m<=n:
if n<=10000100000 and n-m <=100000:
for k in range(m,n+1):
for i in range(1,(k//2)+1):
if k%i==0 and i!=1:
flag=0
break
else:
continue
if flag==1 and k!=1:
print k
else:
flag=1
continue
print (”\n")
else:
print(“error”)

Actually that is the main challenge u just dont have to write a function that solves the problem u have to write the most efficient version u should do something to decrease time complexity by not iterating on the values that u know are already non-prime.
Pls try to improve your code and still if u dont get the answer i will give you the solution.

Hey, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.