how to remove the runtime (NZEC) error in my python code? -
i trying solve prime generator problem prime1 in spoj.com getting runtime error(nzec). problem needs take number of test cases , each test case, needs input 2 numbers in line each different test case , print output prime numbers in range of each number error runtime error time: 0.01 memory: 7736 signal:-1
# code goes here def is_prime(x): if x<2: return false if x==2: return true y in range(2,x): if x%y==0: return false return true t=int(raw_input()) mylist=[] in range(0,t): a=raw_input() a=a.split(' ') mylist.append(int(a[0])) mylist.append(int(a[1])) k=0 while k<len(mylist): c=mylist[k] k+=1 d=mylist[k] k+=1 z in range(c,d+1): if is_prime(z): print z print
your issue raw_input()
returns string , not integer. trying use directly in range()
function - for in range(0,t)
. range()
function accepts integers arguments, need convert input int
before using in range.
t=int(raw_input())
Comments
Post a Comment