dimanche 20 décembre 2020

python else statement confusion [duplicate]

I am new to python programming. I am a little confused in the below code, how else statements work without corresponding if statement. Could anyone please explain to me the below code. Program is Prime number between two intervel.

start=int(input("Enter Number: "))
    stop=int(input("Enter Second Number: "))
    
    for i in range(start,stop):
        if i>1:
            for j in range(2,i//2+1):
                if(i%j==0):
                    break
            
    
            else:
                print(i)

Aucun commentaire:

Enregistrer un commentaire