Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

else clause in for loop python

for n in range(2, 10):
    for x in range(2, n):
        if n % x == 0:
            print( n, 'equals', x, '*', n/x)
            break
    else:
        # loop fell through without finding a factor
        print(n, 'is a prime number')
Source by book.pythontips.com #
 
PREVIOUS NEXT
Tagged: #clause #loop #python
ADD COMMENT
Topic
Name
6+9 =