The choice function takes a general sequence.
Returns a random element from a non-empty sequence seq.
In particular,
random.choice(['A', 'B', 'C', 'D'])
will do what you want.
You can easily generate a range programmatically:
random.choice([chr(c) for c in xrange(ord('A'), ord('D')+1)])
Ami tavory
source share