found = False
for divisor in range(2, n):
    if n % divisor == 0:
        found = True
break
if found:
    print(n, 'is composite')
else:
    print(n, 'is prime')
Pythonic ways to use 'else' in a for loop