def gen_fib(): a, b = 0, 1 while True: yield b a, b = b, a + b def digit_in_fib(n): for x in gen_fib(): print(x) s = str(x) l = len(s) if l >= n: return s[n - 1] n -= l print(digit_in_fib(800))