Contact: aviboots(AT)netvision.net.il
36,641 questions
47,918 answers
573 users
import random sorted_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] randomized_list = random.sample(sorted_list, len(sorted_list)) print(randomized_list) ''' run: [6, 5, 4, 1, 3, 9, 7, 10, 2, 8] '''
import random lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] random.shuffle(lst) print(lst) ''' run: [3, 5, 10, 1, 6, 2, 9, 7, 8, 4] '''
import numpy as np sorted_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] randomized_list = np.random.permutation(sorted_list).tolist() print(randomized_list) ''' run: [6, 7, 8, 3, 4, 5, 9, 1, 10, 2] '''