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 ?

7th Apr 2020, 6:35 PM
Arogbodo Mololuwa
Arogbodo Mololuwa - avatar
2 Answers
+ 5
Letters=[chr(x) for x in range(ord('a'),ord('z'),2)]
7th Apr 2020, 6:48 PM
Oma Falk
Oma Falk - avatar
+ 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)
7th Apr 2020, 7:01 PM
rodwynnejones
rodwynnejones - avatar