def is_prime(num):
    '''Returns whether the given num is prime'''
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

def get_primes():
    '''Get the first 1,000 prime numbers'''
    primes = []
    num = 2
    while len(primes) < 1000:
        if is_prime(num):
            primes.append(num)
        num += 1
    return primes

def print_threes(primes):
    '''Prints the numbers in the list that start or end with 3'''
    for num in primes:
        num_str = str(num)
        if num_str[0] == '3' or num_str[-1] == '3':
            print(num)

result = get_primes()
print_threes(result)
# print(result)
