expand try.py import math def isPrime(candidate): for i in range(2, 1 + int(math.sqrt(candidate))): if candidate % i == 0: return None return 1 results = [] for i in range(2, 25): if isPrime(i): results.append(i) print results