0

Input =>

nums = [1,2,2,100]

print([*set(nums)])

Output = >

[1,2,100]

Input =>

nums = [1,2,2,1000]

print([*set(nums)])

output =>

[1000,1,2]

i don't know the reason

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
  • 5
    `set` is not ordered. The order you get depends on how `set` hashes and buckets its input. There is no guarantee that it will remain the same on two consecutive accesses or that everything won't shuffle when something is added or removed. – tdelaney Nov 24 '22 at 04:36
  • "_i don't know the reason_" -> there is some explanation over in [_Why is the order in dictionaries and sets arbitrary?_](https://stackoverflow.com/a/26099671/674039) – wim Nov 24 '22 at 05:20

0 Answers0