423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

Randomize the contents of a list in-place

P: 1
How would I randomize the contents of a list in-place?
1 Week Ago #1
Share this Question
Share on Google+
1 Reply


P: 5
For this, we’ll import the function shuffle() from the module random.

>>> from random import shuffle
>>> shuffle(mylist)
>>> mylist
[3, 4, 8, 0, 5, 7, 6, 2, 1]
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.