Part of my code involves accessing the pre-defined variables in a for loop. However, trying to access the already existing variables in a for loop doesn't seem to work:
import itertools
def f(x):
x1, x2 = itertools.tee(x)
print(list(x1), list(x2))
for i in range(1):
print(list(x1), list(x2))
f(iter([1,2]))
Is there any way to resolve this?