In python, I tried to create a copy of my iterator using the destination, but it created a copy of the iterator that references the original iterator. For instance:
my_list = [5, 4, 3,2] first_it = iter(my_list) second_it = first_it print next(first_it )
As you see in the example, first_it and second_it both belong to the same fighter. Is it possible to create a copy of an iterator object that is not related to the original object?
Note This question is about creating a copy of the iterator object by value. Therefore, do not call for item in my_list:
similar solutions. thanks in advance
source share