Programming/Python
Python/Code/중복없는 정수 난수 뽑기
현벨
2018. 3. 30. 20:39
반응형
# 소스
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #made by hyeonbell import random S = [] for i in range(26): S.append(i+1) T = [] while T.__len__() < 26: j = int((random.random() * 100) % 26 + 1) if j not in T: T.append(j) for t in T: print(t) | cs |
# 결과
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 10 17 8 14 11 15 9 22 7 16 23 5 1 13 2 4 21 26 12 6 24 25 20 19 3 18 Process finished with exit code 0 | cs |
반응형