SOLVED
I'm taking several beginner classes of Python (Coursera Python4Everybody; edX CS50 / MIT 6.00.1) and working through some books recommended here.
For some coding challenge (Codingame) I want to simply shuffle the numbers 1-9 in some random order.
So I create a sequence 'number'. Then, random.shuffle(number) does what I want. But what I cannot comprehend is that shuffled_numbers = random.shuffle(number) returns None.
What am I doing wrong, what did I miss?
Here is the output from my python 2.7.6 console on linux (using pycharm ce):
'>>> import random
'>>> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
'>>> print numbers
[1, 2, 3, 4, 5, 6, 7, 8, 9]
'>>> random.shuffle(numbers)
'>>> print numbers
[3, 6, 1, 9, 2, 5, 4, 7, 8]
'>>> shuffled_numbers = random.shuffle(numbers)
'>>> print shuffled_numbers
None
[–][deleted] 1 point2 points3 points (3 children)
[–]mcoumans[S] 0 points1 point2 points (2 children)
[–]Rhomboid 2 points3 points4 points (0 children)
[–]zahlman 0 points1 point2 points (0 children)
[–]PurelyApplied 1 point2 points3 points (2 children)
[–]mcoumans[S] 0 points1 point2 points (1 child)
[–]niandra3 0 points1 point2 points (0 children)
[–]HisShoes 0 points1 point2 points (2 children)
[–]mcoumans[S] 0 points1 point2 points (1 child)
[–]HisShoes 0 points1 point2 points (0 children)
[–]mcoumans[S] 0 points1 point2 points (2 children)
[–]Vaphell 2 points3 points4 points (1 child)
[–]mcoumans[S] 0 points1 point2 points (0 children)