DEV Community

Cover image for A-Z with ASCII Code - NLP
datatoinfinity
datatoinfinity

Posted on • Edited on

A-Z with ASCII Code - NLP

A-Z with ASCII code

We are going to print A-Z alphabet using ASCII code.

for asc in range(65,91):
    print(chr(asc))
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

Now we will print it in one line:

print(''.join([chr(asc) for asc in range(65,91)]))
Output:
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Now in reverse order:

print(''.join([chr(asc) for asc in range(90,64,-1)]))
ZYXWVUTSRQPONMLKJIHGFEDCBA

Alphabet in small letter:

print(''.join([chr(asc) for asc in range(97,123)]))
abcdefghijklmnopqrstuvwxyz

Top comments (0)