def iter_sqrt(limit): a, b = 2, 1 for i in range(limit): a, b = b + 2 * a, a yield a - b, b print(len(list(filter(lambda x: len(str(x[0])) > len(str(x[1])), iter_sqrt(1000)))))