When I send a string as a argument in set data structure in python, surprisingly the order has been changed for some characters.
Suppose, If i write
>>> c=set('abcd')
Then I should expect the set c to be shown as {'a', 'b', 'c', 'd'} but it shows output like that:-
>>> c
{'c', 'b', 'd', 'a'}
And more importantly, as far i know set in python only accept an object that is iterable.
So, it is obvious that set would iterate through the string and should maintain the correct order of the string.
I have tested it several times. And every times the order has been changed surprisingly....
I know in python there is nothing called character. A single character is also defined as string. But, since iteration occurs through the string this should be ordered.
So, could someone explain me the reason of the scenario? Is there any insight
in the iteration process or python VM issues ?
* I intended to know the iteration methodology of strings in set, not dict*