+ 1
Why is it not working
def is_prime(num): return [i for i in range(2,num) if num%i == 0] == [] def get_prime(): num = 2 while True: if is_prime(num): yield num num += 1 for i in get_prime(): print(i)
7 Respostas
+ 4
You should indent back the line: num += 1 so that it always gets executed, not only in case the if statement is True...
+ 3
change while True to
while num <10000
+ 3
Valmob101
Yes.the problem is there too.
It gives output sometimes and sometimes not.
+ 2
I Hope it will help you out!!
https://code.sololearn.com/cQ7v3VCq2Ul9/?ref=app
+ 1
dedent num+=1
+ 1
Move num += 1 one indentation back.
It is basically the memory issue with sololearn. Sometimes it works and sometimes not.
Use for loop or while loop with condition instead to get result.