If you have a list of items or a sequence and you want to pic a random item from said sequence. Here is a quick way to do it

from random import choice

letters = ['a', 'b', 'c', 'd']

print(choice(letters))

January 1, 2015


Previous post
Python one liner refactors I like it when I find one liner that make the code better and and faster to understand. The worst one liners are those that force you to twist you
Next post
Counting Set Bits ###Description: Write a function that takes an (unsigned) integer as input, and returns the number of bits that are equal to one in the binary