0

Hello to all!How can i make a list from all the small letters of the alphabet without writing every one?Is there an operator/function that does that,something like .I've tried in many ways but i'm new in Python and if there is that operator i haven't discover it yet.My appreciation!

3
Contributors
5
Replies
7
Views
12 Years
Discussion Span
Last Post by coder_gus
0

This will do it ...

print "Fill a string with a - z:"
alphaStr = ""
# letters a to z are ASCII code 97 to 122
for k in range(97, 123):
  alphaStr += chr(k)

print alphaStr

# if you don't have an ASCII table handy let Python do it ...
print "ord('a') =", ord('a')
print "ord('z') =", ord('z')

Edited by vegaseat: fixed code tags

0

Hi!

Python comes with batteries included ;)

>>> import string
>>> string.lowercase
'abcdefghijklmnopqrstuvwxyz'

Regards, mawe

0

Thanks mawe, welcome to this tiny Python corner. So a simple ...

import string
alphaStr = string.lowercase

print alphaStr

... would have done it. I guess it pays to run ...

help('string')

Thanks again!

0

Thanks a lot guys.It's great to know that we can help each other once in a while.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.