import math def isPrime(n): for i in range(2,int(math.sqrt(n))+1): if(n%i==0): break if(i==int(math.sqrt(n))): return True else: print(i) return False
n1,n2=map(int,input().split()) list1=[] for j in range(n1,n2+1): if(isPrime(j)): list1.append(j) print(list1) _________________________________ i/p: 3 45 Traceback (most recent call last): File "C:\Users\GRIET\AppData\Local\Programs\Python\Python37-32\isPrime.py", line 14, in if(isPrime(j)): File "C:\Users\GRIET\AppData\Local\Programs\Python\Python37-32\isPrime.py", line 6, in isPrime if(i==int(math.sqrt(n))): UnboundLocalError: local variable 'i' referenced before assignment