randomly pick a value in the list

Solutions on MaxInterview for randomly pick a value in the list by the best coders in the world

showing results for - "randomly pick a value in the list"
Teddy
29 May 2017
1import random
2
3l = [0, 1, 2, 3, 4]
4
5print(random.sample(l, 3))
6# [1, 3, 2]
7
8print(type(random.sample(l, 3)))
9# <class 'list'>
10