shuffle list

Do you want to know the details regarding “shuffle list”. If yes, you’re in the correct article.

shuffle list

import random
number_list = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
print ("Original list : ",  number_list)

random.shuffle(number_list) #shuffle method
print ("List after shuffle  : ",  number_list)
import random

random.shuffle(list)
import random

number_list = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]
print("Original list:", number_list)

random.shuffle(number_list)
print("List after first shuffle:", number_list)

random.shuffle(number_list)
print("List after second shuffle:", number_list)
//Shuffles a list using durstenfeld algorithm
shuffle(a)
var j, m, i
for (i = a.length - 1; i > 0; i--) 
  j = Math.floor(Math.random() * (i + 1));
  m = a[i]
  a[i] = a[j]
  a[j] = m;

return a;

Final Words

I hope this article helps you to know about “shuffle list”. If you have any doubts regarding this tutorial please let us know via the comment section. Share this tutorial with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment