+ 3
To randomize the items of a list
I have written a code. is it correct? or can there be some more logical way? thanx https://code.sololearn.com/crzsl7GOHll1/?ref=app
6 Respostas
+ 4
You could get it shorter, but more shorter means not better.
import random as r
l=[18,64,648,83,"hello","bye"]
print(r.choice(l))
I think your code is okay.
+ 4
It looks very nice. Just a little comment, choice and shuffle work different, choice returns a random element of the list and shuffle randomize all the list. So I wouldn't change the shuffle for choice, unless I require a single element instead of the whole list
+ 3
thanx Lucky Luke
+ 2
Your code is very good, it does not need to be improved!😀
+ 2
Nilutpol Kashyap You 're welcome!
+ 1
Laura Madrigal thanx