Inplace shuffle function returns none

Ian Kelly ian.g.kelly at gmail.com
Tue Oct 18 17:05:01 EDT 2016


On Tue, Oct 18, 2016 at 2:25 PM, Sayth Renshaw <flebber.crue at gmail.com> wrote:
> So why can't i assign the result slice to a variable b?
>
> It just keeps getting none.

Because shuffle returns none. If you want to keep both the original
list and the shuffled list, then do something like:

b = a[:]
shuffle(b)
print(a)
print(b)

Copy it first, then shuffle it.



More information about the Python-list mailing list