-3

If I have a string

alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

and I want to make a list like

alph = ["A", "B", "C", ...]

How would I do it?

Georgy
  • 12,464
  • 7
  • 65
  • 73
Mohit M
  • 29
  • 4
  • 3
    Should've closed it as a duplicate of [How to split a string into array of characters?](https://stackoverflow.com/q/4978787/7851470) – Georgy Jun 22 '20 at 17:43

2 Answers2

4

python already gives us the uppercase letters as a string we can convert it to a list.

from string import ascii_uppercase
print(list(ascii_uppercase))

OUTPUT

['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']
Chris Doyle
  • 10,703
  • 2
  • 23
  • 42
0

You mean something like this?

list(alph)

Output:

[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]
IMB
  • 519
  • 4
  • 19