-1

so, in my book state that:

dict1 = {'satu': 100, 'dua': 100, 'tiga': 100, 'empat':200}
set1 = set(dict1)
set1
{'tiga', 'dua' 'empat' 'satu'}

and while i try it, the code says:

dict1 = {'satu': 100, 'dua': 100, 'tiga': 100, 'empat':200}
set1 = set(dict1)
set1
{'satu', 'dua' 'empat' 'tiga'}

am i mising something? My code here[text] Book Code description here

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • my book is using python 3.6 for refrence, sorry i forgot to mention it before. – Raza Freza Aug 25 '23 at 09:26
  • 1
    Order of the elements in set can change. So you can not expect elements to appear in the same order as they are in book. Main point to note is that set has unique elements. – user2298124 Aug 25 '23 at 09:29

2 Answers2

1

In the documentation it clearly says that:

A set is an unordered collection with no duplicate elements.

So the order doesn't count, the only thing that matters, in your case, is that the elements of the set are the same as the ones displayed in the book.

0

Order of the elements in set can change. So you can not expect elements to appear in the same order as they are in book. Main point to note is that set has unique elements.

user2298124
  • 341
  • 2
  • 7