File size: 203 Bytes
42da440
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import random


def sample_and_remove(lst, n):
    sampled = []
    for _ in range(min(n, len(lst))):
        index = random.randrange(len(lst))
        sampled.append(lst.pop(index))
    return sampled