0
Python (Range)
Is it possible to also ranger letters, for example. letters = list(range(a,z,2) print (letters) and expect to have: >>> [a,c,e,g,i,k,m,o,q,s,u,w,y] >>> something like this ?
2 Answers
+ 5
Letters=[chr(x) for x in range(ord('a'),ord('z'),2)]
+ 4
Amended..
import string
thealphbet = string.ascii_lowercase
mylist = []
for x in range(0, len(thealphbet), 2):
mylist.append(thealphbet[x])
print(mylist)
#or.... similar to Oma Falk..
import string
letters = [x for x in string.ascii_lowercase[::2]]
print(letters)