+ 1
Why the output of this code is 4 ? Please explain
Nums= set ([1,1,2,3,3,3,4]) Print (Len(nums))
2 Antworten
+ 1
"set” does not set the same item more than once. so for example:
items = set([“once”, “once”])
if I print “items” it will only show:
{“once”}.
So your set is setting 1:1, 1:2, 1:3 and 1:4. the length of 4 is 4 so you are seeing it print 4.
+ 3
A set has no duplicate element.