I am trying to code a caesar’s cipher
I have this piece of code:
letters = ‘abcdefghijklmnopqrstuvwxyz’
`
and when I try and add a position this happens
position = letters.index(character)
NameError: name ‘character’ is not defined
I expected for it to give me the index of each letter
>Solution :
Is this what you are looking for?
letters = 'abcdefghijklmnopqrstuvwxyz'
for i in letters:
print(i, letters.index(i))
This will yield an output:
a 0
b 1
c 2
d 3
e 4
f 5
g 6
h 7
i 8
j 9
k 10
l 11
m 12
n 13
o 14
p 15
q 16
r 17
s 18
t 19
u 20
v 21
w 22
x 23
y 24
z 25