else Statement ... Take Two : While : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » While »

 

else Statement ... Take Two


#!/usr/bin/env python

def showMaxFactor(num):
    count = num / 2
    while count > 1:
         if num % count == 0:
             print 'largest factor of %d is %d' % (num, count)
             break
         count -= 1
    else:
         print num, "is prime"

for eachNum in range(1021):
    showMaxFactor(eachNum)



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Statement
» While