why the set print value is ordered when the loop nums become large?

Viewed 72

it is python 3.8, when input 10, the print(s) is random, but when input 900, the print(s) is ordered same as print(sorted(s))

import random

s = set()

for i in range(int(input("loop nums:\n"))):
    vv = random.randint(1, 1000)
    s.add(vv)

print(s)
print(sorted(s))
0 Answers
Related