Updating a set while iterating over its elements
问题 When I try to update a set while iterating over its elements, what should be its behavior? I tried it over various scenarios and it does not iterate over elements added after iteration is started and also the elements removed during iteration. If I remove and put back any element during iteration, that element is being considered. What's the exact behavior and how does it work? This prints all the permutations of a string: def permutations(s): ans = [] def helper(created, remaining): if len