G
Guest
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
'z']? The range() just can generate the numeric list.
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
äººè¨€è½æ—¥æ˜¯å¤©æ¶¯ï¼Œæœ›æžå¤©æ¶¯ä¸è§å®¶ said:Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? Â The range() just can generate the numeric list.
import string
list(string.lowercase)
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? Â The range() just can generate the numeric list.
äººè¨€è½æ—¥æ˜¯å¤©æ¶¯ï¼Œæœ›æžå¤©æ¶¯ä¸è§å®¶ said:Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? Â The range() just can generate the numeric list.
There is:
[ chr(i) for i in range(97, 123) ]
Thomas
Be careful here. If you change locale that will return all lowercaseMichael Bentley said:Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
import string
list(string.lowercase)
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
Not very simple, but how about a list comprehension:
import string
lst = [char for char in string.letters[:26] ]
print lst
Be careful here. If you change locale that will return all lowercaseMichael Bentley said:Is there a simple function to generate a list like ['a', 'b',
'c', ...
'z']? The range() just can generate the numeric list.
import string
list(string.lowercase)
letters not just 'a' to 'z'. For example:
abcdefghijklmnopqrstuvwxyzƒšœžªµºßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.