#shuffle, sample
from random import*
lst = [1,2,3,4,5]
print(lst)   #[1,2,3,4,5]
shuffle(lst)
print(lst)   #[2,3,1,5,4]  무작위로 섞음
print(sample(lst,2))  #lst안에서 2개를 무작위로 뽑음 [2,1]
반응형

'Python' 카테고리의 다른 글

18. for(반복문)  (0) 2023.05.22
17. if(조건문)  (0) 2023.05.22
15. 자료구조의 변경  (2) 2023.05.22
14. 세트(집합)  (0) 2023.05.22
13. 튜플  (0) 2023.05.22

+ Recent posts