0
Why repeated number are not printed in set? Does same thing happens in dictionary? nums = {1, 2, 1, 3, 1, 4, 5, 6} print(nums)
nums = {1, 2, 1, 3, 1, 4, 5, 6} print(nums)
5 Réponses
+ 6
this is what makes a set:
no dups.
+ 5
in dicts keys are unique.
last one wins.
+ 2
Zahed Shaikh
It's very simple sets doens't allow duplicate values.
+ 1
I assume that the programmers who implemented the set had a condition that checks if the given value already exists in the set. If it exists- the given number won't be added..
+ 1
+ 2 Cents to all above mentioned things:
sets are not ordered.
i.e.:
they will appear randomly every time.