By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,668 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,668 IT Pros & Developers. It's quick & easy.

Randomize the contents of a list in-place

P: 5
How would I randomize the contents of a list in-place?
Dec 7 '18 #1
Share this Question
Share on Google+
1 Reply


P: 3
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]
Dec 7 '18 #2

Post your reply

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