javanewbie javanewbie - 1 year ago 76
Python Question

Is there a random letter generator with a range?

I was wondering if there is a random letter generator in Python that takes a range as parameter?
For example, if I wanted a range between A and D? I know you can use this as a generator:

import random
import string


But it doesn't allow you to supply it a range.

Answer Source

You can slice string.ascii_letters:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download