Ask coding questions

← Back to all posts
1
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 (485) [earned 5 cycles]
View Answer
Commentshotnewtop
1
ebest (485)

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

1
DhruvDarda (0)

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

1
ebest (485)

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