while and else : While : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » While »

 

while and else


y = 8
x = y / 2                                 # For some y > 1
while x > 1:
    if y % x == 0:                        # Remainder
        print y, 'has factor', x
        break                             # Skip else
    x = x-1
else:                                     # Normal exit
    print y, 'is prime'



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» While