# -*- coding: utf-8 -*- # def fibonacci(n): # a = 0 # b = 1 # nums = [] # for _ in range(n): # nums.append(a) # a,b = b,a+b # return nums # for i in fibonacci(10): # print(i) def fibonacci(n): a = 0 b = 1 for _ in range(n): yield a a,b = b,a+b for i in fibonacci(10): print(i)