Overload __setitem__ method to for item setter operator
Overload __setitem__
__setitem__(self, key, value)
stores key-value pair.
So the value can later be retrieved with __getitem__
.
This method is only for mutable objects.
For a sequence, if the key is a negative integer, it should be used to count from the end.
In other words, treat x[-n]
the same as x[len(x)-n]
.