How to add a List to a Set in Python
If you need to add a list
to a set
in Python, then you can do the following:
Option 1 – Using Tuple
Output: {1, 2, 3, 4, (1, 2, 3)}
Option 2 – Using set.update()
Output: {1, 2, 3, 4, 8, 9, 12}