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,989 questions

51,934 answers

573 users

How to shuffle a list in Python

2 Answers

0 votes
from random import shuffle

lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

shuffle(lst)

print(lst)



'''
run:

[8, 7, 4, 6, 5, 3, 1, 10, 2, 9]

'''

 



answered May 13, 2018 by avibootz
edited Apr 28, 2024 by avibootz
0 votes
import random
 
lst = [34, 78, 90, 'python', 'java', 'c++']
 
random.shuffle(lst)
 
print(lst) 
 
 
 
 
'''
run:
 
['c++', 'python', 34, 'java', 90, 78]
 
'''

 



answered Apr 28, 2024 by avibootz

Related questions

1 answer 164 views
164 views asked Oct 7, 2019 by avibootz
1 answer 61 views
61 views asked Nov 4, 2024 by avibootz
2 answers 184 views
184 views asked Apr 24, 2021 by avibootz
2 answers 110 views
110 views asked Mar 25, 2023 by avibootz
1 answer 106 views
106 views asked Oct 18, 2022 by avibootz
1 answer 186 views
186 views asked Oct 31, 2021 by avibootz
3 answers 331 views
331 views asked Jul 31, 2018 by avibootz
...