Recursion using yield

前端 未结 4 1041
粉色の甜心
粉色の甜心 2020-11-28 05:41

Is there any way to mix recursion and the yield statement? For instance, a infinite number generator (using recursion) would be something like:

         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 05:51

    So basically you just need to add a for loop at where you need to call your function recursively. This applies for Python 2.7.

提交回复
热议问题