list({3,2,1}) == [1,2,3] :True | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

list({3,2,1}) == [1,2,3] :True

(From a challenge) We know order is a meaningless concept for sets. I think this behavior (sorting before converting to list) is not a rule. Although it seems to always happens for numbers (not for characters). What do you guys think?

22nd Sep 2021, 8:02 PM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
4 Answers
+ 6
mesarthim thank you for responding. In fact {3,2,1} is a set, in python.
22nd Sep 2021, 8:33 PM
Arsalan [Inactive]
Arsalan [Inactive] - avatar
+ 2
Hi Arsalan! No, it's the same for characters since set stores the elements in a random manner. We can see that here. https://code.sololearn.com/c62I3TyzNjzv/?ref=app
23rd Sep 2021, 3:32 AM
Python Learner
Python Learner - avatar
+ 1
As I know, we can write a list element with using both { } and [ ] so the given is true.
22nd Sep 2021, 8:10 PM
mesarthim
mesarthim - avatar