How to initialize a list with ascii uppercase letters in Python

3 Answers

0 votes
import string

lst = list(string.ascii_uppercase)

print(lst)



'''
run:

['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

'''

 



answered May 14, 2019 by avibootz
0 votes
import string

lst = list(map(chr, range(65, 91)))

print(lst)



'''
run:

['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

'''

 



answered May 14, 2019 by avibootz
0 votes
import string

lst = list(map(chr, range(ord('A'), ord('Z') + 1)))

print(lst)



'''
run:

['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

'''

 



answered May 14, 2019 by avibootz

Related questions

...