mercredi 28 août 2019

how to fix the syntax error in prime number program?

Iam getting syntax error near else part and how to set right indendation?

I tried running on Py3

num=int(input("enter the no"))
if(num>1):
    for i in range(2,num):
        if(num%i==0):
            print("not prime",num)
            break;
        else:
            print("prime",num)
        else:
            print("not prime",num)

Aucun commentaire:

Enregistrer un commentaire