Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,970 questions

51,912 answers

573 users

How to shuffle an array in Python

2 Answers

0 votes
import numpy as np
import random

arr = np.array((1, 2, 3, 4, 5, 6))
 
random.shuffle(arr)
 
print(arr) 
 
 
 
 
'''
run:
 
[4 3 1 5 6 2]
 
'''

 



answered Apr 24, 2021 by avibootz
0 votes
import numpy as np
  
arr = np.random.permutation(10)
 
print(arr)
 
   
   
   
   
'''
run:
  
[1 4 6 9 0 7 2 8 3 5]
 
'''

 



answered Apr 28, 2024 by avibootz

Related questions

1 answer 60 views
60 views asked Nov 4, 2024 by avibootz
1 answer 162 views
162 views asked Oct 7, 2019 by avibootz
2 answers 264 views
264 views asked May 13, 2018 by avibootz
2 answers 142 views
142 views asked Nov 8, 2023 by avibootz
1 answer 102 views
102 views asked Jan 4, 2023 by avibootz
1 answer 86 views
86 views asked Jan 4, 2023 by avibootz
...