-1
import random 

nums1 = [1,2,3]
nums2 = [random.shuffle(nums1)]
print nums2

how can I get nums2 as a list ?

Ahsanul Haque
  • 10,676
  • 4
  • 41
  • 57
Joe
  • 3
  • 5

1 Answers1

1

random.shuffle() returns None. So, you are getting a list with element None.

random.shuffle() shuffles a list in place. So print nums1.

However, if you want to have a new shuffled list, first do:

nums2 = nums1[:]

That will make a new copy of nums1

Then do:

random.shuffle(nums2)
print nums2
Ahsanul Haque
  • 10,676
  • 4
  • 41
  • 57