Reputation: 757
if I have this List in Flutter :
var myList = ["a","b" , "c" , "d"];
How to create new list from myList by random index for each value like :
["b","c" , "a" , "d"];
or :
["a","c" , "d" , "b"];
or any other random list
Upvotes: 1
Views: 57
Reputation: 739
Try this:
var myList = ["a", "b", "c", "d"];
myList.shuffle();
Upvotes: 0
Reputation: 15
import random
myList = ["a","b" , "c" , "d"];
random.shuffle(myList)
print(mylist)
You follow this https://www.w3schools.com/python/ref_random_shuffle.asp
Upvotes: 1