Cannot shuffle list in Python

假如想象 提交于 2020-01-04 04:03:10

问题


This is my list:

biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ]
print random.shuffle(biglist)

that doesn't work! It returns none.


回答1:


random.shuffle shuffles the list, it does not return a new list. So check biglist, not the result of random.shuffle.

Documentation for the random module: http://docs.python.org/library/random.html



来源:https://stackoverflow.com/questions/1530161/cannot-shuffle-list-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!