I will tell a couple of answers. The easiest way to get some list is to use the notation slice:
pl = pl[:5]
If you really want to jump out of the list, this works:
while len(pl) > 5:
pl.pop()
If you are after a random selection of options from this list, this is probably the most effective:
import random
random.sample(range(10), 3)
source
share