Menu

gitpiper

sample python Code Snippet in 2024

listrandombeginner

Last Updated: 6 April 2024

Returns a random element from a list.

  • Use random.choice() to get a random element from lst.
from random import choice def sample(lst): return choice(lst)
sample([3, 7, 9, 11]) # 9

python snippet similar to sample For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️