What is the difference between random.sample and random.shuffle in Python

后端 未结 6 1671
生来不讨喜
生来不讨喜 2021-01-20 00:23

I have a list a_tot with 1500 elements and I would like to divide this list into two lists in a random way. List a_1 would have 1300 and list a_2 would have 200 elements. My

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 00:41

    The randomization should be just as good with both option. I'd say go with shuffle, because it's more immediately clear to the reader what it does.

提交回复
热议问题