nums = [12, 34, 23, 56]
print "Original array:\n"
print nums
print "\n 2 random elements from the array.\n"
print nums.sample(2)
print "\n 3 random elements from the array.\n"
print nums.sample(3)
Output:
Original array:
[12, 34, 23, 56]
2 random elements from the array.
[34, 12]
3 random elements from the array.
[56, 12, 34]
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer