Ask coding questions

← Back to all posts
please tell me why i find this error in the program of prime numbers
DhruvDarda (0)

#prime nuber
import time
import math as m
start=time.time()
a=input('enter the no till which prime nos are to be printed ')
int(a,2)
i=2
count=0
prime=[2]
while i<=a:
for x in range(2,sqrt(i),1):
if i%x==0:
count=0
break
else:
count=1
if count==1:
prime_list.append(i)
i+=i
print(prime)
end=tme.time()
print(end-start)

Answered by ebest (574) [earned 5 cycles]
View Answer
Commentshotnewtop
ebest (574)

Because you should be using either spaces or tabs. Here, print(i) is using spaces, while everything else uses tabs.

Click the check mark next to this comment!

-Ebest

DhruvDarda (0)

@ebest
still i am not able to run the program successfully ..

ebest (574)

@DhruvDarda You didn't fix it. What's a "nos"?