How do sets work in Python?
<pre><code>&gt;&gt;&gt; {x for x in 'spam'}
{'a', 'p', 's', 'm'}
</code></pre>

<p>Why does it change the order? If you take a look at a loop, it works perfectly:</p>

<pre><code>&gt;&gt;&gt; for x in 'spam':
...     print(x)
... 
s
p
a
m
&gt;&gt;&gt; 
</code></pre>
