last day (15 days later) » 

10:52 AM
2
A: get positive non-prime numbers for a range in python

Prasanth Ganesanfrom math import sqrt def is_prime(num): for i in range(2,int(sqrt(num))+1): if num % i == 0: return False return True def yield_np(n): np_counter = 1 num_to_print = 1 while np_counter <= n: if num_to_print == 1 or is_prime(num_to_print) == False: ...

 
Hi @ParthS007 how can I yield the non-prime numbers to the generator, so it can prints only non-prime numbers?
 
I have edited my answer, check it out
Try giving 10 as input. Most of the coding challenges will not ask you for a prompt. So I have not given a prompt like 'enter n value'. Just run the program and provide the input
 
I have added a Latest Update in the question, take a look, please! What I'm doing wrong there?
 
I don't understand your logic and why do you have nested functions? I have given the solution for your problem.
 
as I said, it's a code challenge, so there I have only one function in which I have to write the complete code, that's I have adjust it in this way.
 
10:52 AM
You say you have only one function. What's the name of that function and how many params does it take? Please provide the details
 
It’s locked we can not change the part below positive_integers_generator.
 
Ok I understood your problem. I got confused because of too much info you have provided in your question
Please provide a clear definition of positive_integers_generator(). Only if you provide the full definition, I can help you
 
I have posted the complete definition of this function.
 
hey
can you upload a screenshot of your coding challenge?
 
hi
here's I have found another solution wich is also just near to the working solution:
there?
are you there? please!
 
10:59 AM
Hey i just looked at the images
 
it's ok!
 
I'll tell you ince I update my answer.
 
have you taken a look at the python forum thread?
 
no. which thread? can you be more clear?
 
11:08 AM
So have you got the solution?
 
not!
just giving this to you, it may help!
I'm waiting for your updated answer.
 
In five minutes
```for _ in range(k):
n = next(g)
print(n)```
I have a doubt here. Are you printing n? Or is it provided alreasy>
already*
 
it's provided in this way, this is the part which is not editable, it's locked on hackerrank!
 
I am getting confused. Can you send the hackerrank link?
 
have you taken a look at the link i have sent you above?
actually, you can't access the hackerrank test because it's protected.
here's the link if you want to give it a try: hackerrank.com/tests/66g0bossg4s/questions/3lpe25ll8jj
 
11:40 AM
there?
 
11:51 AM
Sorry I am in a meeting. :(
 
12:15 PM
it's ok, I will wait for your reply!
 

last day (15 days later) »