Python Set Comprehensions -


this question has answer here:

i'm starting out learning python set comprehensions. why { 2**x x in {0,1,2,3,4} } return {8, 1, 2, 4, 16} instead of ordered {1, 2, 4, 8, 16}?

mathematically speaking, sets not have order. when displaying or iterating on set, python needs provide particular order, order arbitrary , not relied on. order is, however, fixed particular set; iterating on same, unmodified set produce same order each time.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -