Tech > Coding Challenges > HackerRank > Prepare > Python > Set > Set Mutations

Problem Link to the original HackerRank problem We have seen the applications of union, intersection, difference and symmetric difference operations, but these operations do not make any changes or mutations to the set. We can use the following operations to create mutations to a set: .update() or |= Update the set by adding elements from an iterable/another set. >>> H = set("Hacker") >>> R = set("Rank") >>> H.update(R) >>> print H set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R']) .intersection_update() or &= ...

January 27, 2024 · 4 min · 666 words