0

What is the different

I have 2 codes: def is_prime(num): for k in range(2,num): if num % k ==0: return False return True def prime_number(x): for i in range(3,x): if is_prime(i): yield i print(list(prime_number(1000000))) and def is_prime(num): for k in range(2,num): if num % k ==0: return False return True def prime_number(x): for i in range(3,x): if is_prime(i): yield i for i in prime_number(1000000): print(i) why only 2nd one print prime numbers but 1st dont? Can anyone help me explain. Thanks you a lot

22nd Jan 2020, 8:55 AM
S.T Hentaro
S.T Hentaro - avatar
4 Respostas
22nd Jan 2020, 9:56 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
I don't understand, what is your question exactly ?
22nd Jan 2020, 9:06 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
I just fixed the question. So the main part here is why the 1st printed None. Sorry for my bad English
22nd Jan 2020, 9:52 AM
S.T Hentaro
S.T Hentaro - avatar
0
thanks you. Now i understand
22nd Jan 2020, 11:24 AM
S.T Hentaro
S.T Hentaro - avatar