Iteration order of sets in Python -
If I have two equal sets, which means a == b
me True
, will they have a single order of travel? I tried to do this, and it works:
gt; & Gt; Foo = Sets ("ABC") & gt; & Gt; & Gt; Bar = set ("ABC")> & Gt; & Gt; My question (zip) (zip, foo, bar) [('a', 'a'), ('c', 'c'), ('b', 'b')]
Is I lucky, or is this the guarantee of this behavior?
This bus is a coincidence that they exit only one: Implementation It has to be deterministic, so the creation of a single set produces the same sequence twice.
n = set ("abc") print nm = set ("kabc") If you create a single set in two different ways: ") M. Rev. (" K ") Print M
... You can get different orders:
set ( ['A', 'C', 'b']) set (['a', 'b', 'c'])
Comments
Post a Comment