+ 2

Help me with this code guys

This is my code for printing prime numbers for given range. (Total no of prime numbers) I could not pass some test cases and the cases are hidden . can you guys help me with debugging and solve it fulfilling all the test case I have inserted the code separately too. import math l,r=input().split() l =int(l) r=int(r) lis=[] lis=list(range(l,r+1)) for i in range(2,r+1): if i in lis: for j in range(i*2,r+1,i): if j in lis: lis.remove(j) print(len(lis)) https://code.sololearn.com/cFN10WLxja5c/?ref=app

9th Apr 2020, 7:55 AM
Binto_ Sharon
Binto_ Sharon - avatar
14 Antworten
9th Apr 2020, 8:25 AM
John Robotane
John Robotane - avatar
+ 2
https://code.sololearn.com/c46bCz5wXMur/?ref=app
9th Apr 2020, 8:11 AM
Enrique Flores
Enrique Flores - avatar
+ 2
add a function from sympy
10th Apr 2020, 11:27 AM
Mantafounis Panagiotis
Mantafounis Panagiotis - avatar
+ 1
the program could use some improvements but its working fine
9th Apr 2020, 8:04 AM
Enrique Flores
Enrique Flores - avatar
+ 1
i would just check for wrong input with try except
9th Apr 2020, 8:05 AM
Enrique Flores
Enrique Flores - avatar
+ 1
maybe it doesnt accepts usage of sympy
9th Apr 2020, 8:25 AM
Enrique Flores
Enrique Flores - avatar
0
Thanks so much for your response love you guys
9th Apr 2020, 8:21 AM
Binto_ Sharon
Binto_ Sharon - avatar
0
look at my code
9th Apr 2020, 8:22 AM
Enrique Flores
Enrique Flores - avatar
0
just added a function from sympy which does all the job :)
9th Apr 2020, 8:22 AM
Enrique Flores
Enrique Flores - avatar
0
Thank you so much
9th Apr 2020, 8:37 AM
Binto_ Sharon
Binto_ Sharon - avatar
0
it worked?
9th Apr 2020, 8:37 AM
Enrique Flores
Enrique Flores - avatar
0
The problem with the test case was if 0 and 1 are given as input ,we have to remove them that's all bruv.
9th Apr 2020, 8:43 AM
Binto_ Sharon
Binto_ Sharon - avatar
0
And the if statement must also be removed .Thanks to john
9th Apr 2020, 8:52 AM
Binto_ Sharon
Binto_ Sharon - avatar