+ 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
10 Respuestas
+ 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.
0
How do I do that
0
Have you read about for loops?
0
Yes
0
So I should do for I in range(10)
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))
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
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
0
I did post it here
0
That https link