Instead of making a list of alphabet like this:
alpha = ['a', 'b', 'c', 'd'.........'z']
Is there any way that we can group it to a range or something? For example, for numbers it can be grouped using range()
range(1, 10)
Instead of making a list of alphabet like this:
alpha = ['a', 'b', 'c', 'd'.........'z']
Is there any way that we can group it to a range or something? For example, for numbers it can be grouped using range()
range(1, 10)
Here is a simple letter-range implementation:
Code
Demo
In Python 2.7 and 3 you can use this:
As @Zaz says:
string.lowercase
is deprecated and no longer works in Python 3 butstring.ascii_lowercase
works in bothIf you really need a list:
And to do it with
range
Other helpful
string
module features: