+ 1
Why 40 is the 5th number of this set in the below code?
5 Respuestas
+ 2
set is unordered, therefore the index of 40 has no meaning.
why does 40 happen to be 5th? Python knows... Python somehow decides it "under the hood".
it is not guaranteed that the set elements will have the same output order when we run it somewhere else.
I suppose it is similar to dict in older Python version (in the latest version key-order is preserved)
+ 2
Thanks Lisa for your explanation but is there any way to sort a set in python?
+ 1
The link took me to this question only .
+ 1
The future is now thanks to science
Haven't used it myself, but maybe this can help you:
https://pypi.org/project/ordered-set/
0
Sorry Abhay .That was a network issue, changed it