프로그래밍/Python
16. shuffle , sample
mimi04
2023. 5. 22. 16:27
#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]
반응형