mardi 1 septembre 2020

If else statement indentation [duplicate]

In the given code i am using else statement outside if statement so is it correct.

for num in range(15,25):
     for i in range(2,num):
         if num%i ==0:
             print("found a factor ",(i)," for ",num)
             break
     else:
           print(num,"is a prime number")

Aucun commentaire:

Enregistrer un commentaire