Unexpected behavior when copying iterators using tee

后端 未结 0 576
暖寄归人
暖寄归人 2021-01-04 04:35

If you copy an iterator inside a for loop, the iteration resumes just fine. For example:

ita = iter(range(5))
for a in ita:
    print(a)
    if a == 2:
               


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题