163579/are-python-sets-mutable
x = set([11, 12, 13]) y = x y |= set([14, 15, 16])
Are x and y still pointing to the same object, or was a new set created and assigned to y?
Python sets are data structures which are used to store values. Sets are unique in the sense that they will not hold duplicate values, also sets are unordered. There are frozen class of sets which are immutable and also a class exists where sets can be changed.
An Example:
x = set([1, 2, 3]) y = x
y |= set([4, 5, 6])
y
Output
{1, 2, 3, 4, 5, 6}
x
Both x and y are set and are same.
>>>> x = set([4, 5, 6]) Sets are ...READ MORE
A frozen set in Python is a ...READ MORE
AND - True if both the operands ...READ MORE
There are 4 types of dictionary Empty Integer Mixed Dictionary with ...READ MORE
suppose you have a string with a ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
Lists can contain duplicates but sets cannot Sets ...READ MORE
The reason is that they are using ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.