I tried to make a simple python code to print prime numbers but it is not working as I expected can someone help please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I tried to make a simple python code to print prime numbers but it is not working as I expected can someone help please

https://code.sololearn.com/cqjS86SC9ZHf/?ref=app

18th May 2020, 1:35 PM
Ashraf Vp
Ashraf Vp - avatar
10 Answers
+ 1
Please be clear for you want to print all prime numbers in a range or want to check if a given number is prime. Also keep in mind that a number is prime if it is divisible no number other than itself and 1.
18th May 2020, 1:39 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
How do I do that
18th May 2020, 1:40 PM
Ashraf Vp
Ashraf Vp - avatar
0
Have you read about for loops?
18th May 2020, 1:45 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
Yes
18th May 2020, 1:46 PM
Ashraf Vp
Ashraf Vp - avatar
0
So I should do for I in range(10)
18th May 2020, 1:46 PM
Ashraf Vp
Ashraf Vp - avatar
0
def isprime(n): for i in range(2,n): if(n==1) return false if(n==2): return true if(n%i==0):#if number is divisible by any of these return false return false return true print(isprime (n))
18th May 2020, 1:50 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
You may not be clear with the code I guess, I would recommend you start learning from the course and I think they have taught this program
18th May 2020, 1:55 PM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
50Legendary Remnant, this question is about the same as your last one. Please ask each question only once. Also, in this linked code, you have only written what Abhay posted and then deleted. Where's your own failed attempt which you have been talking about before? https://www.sololearn.com/Discuss/2300368/?ref=app
18th May 2020, 1:56 PM
HonFu
HonFu - avatar
0
I did post it here
18th May 2020, 2:04 PM
Ashraf Vp
Ashraf Vp - avatar
0
That https link
18th May 2020, 2:04 PM
Ashraf Vp
Ashraf Vp - avatar