I am trying to generate a list comprehension for first 10 letters.
letters = [l for l in 'a-j']
print(letters)
Output:
['a', '-', 'h']
This doesn't produce the expected output.How do I generate a list of first 10 alphabets?
I am trying to generate a list comprehension for first 10 letters.
letters = [l for l in 'a-j']
print(letters)
Output:
['a', '-', 'h']
This doesn't produce the expected output.How do I generate a list of first 10 alphabets?
Use string.ascii_lowercase
which contains the lowercase alphabets stored by default.
>>> import string
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> list(string.ascii_lowercase[:10])
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']